Skip to content

Files

spring-faces

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Apr 1, 2018
Apr 1, 2018
Apr 2, 2018
Apr 1, 2018
Apr 1, 2018
Apr 1, 2018
Apr 2, 2018
Apr 18, 2020
Apr 1, 2018
Apr 1, 2018
Apr 1, 2018
Apr 1, 2018
Apr 1, 2018
Apr 1, 2018
Jun 30, 2021
Apr 1, 2018

spring-faces

spring-faces

Spring + JSF (Prime Faces)

Deployed to: - Glassfish 5.0 - apache tomcat 9.0.6

spring / JSF integration

Faces knows about spring: src/main/webapp/WEB-INF/faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.2"
              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
              http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

  <!-- spring -->
  <application>
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
  </application>

</faces-config>
Web project knows about spring: src/main/webapp/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

  <!-- spring -->
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>

</web-app>
Spring configuration src/main/webapp/WEB-INF/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-4.3.xsd">

  <context:component-scan base-package="daggerok" />
</beans>

build, run, test

./mvnw clean package com.dkanejs.maven.plugins:docker-compose-maven-plugin:1.0.1:up
curl localhost:8080/app/
curl --insecure https://127.0.0.1:4848/
./mvnw com.dkanejs.maven.plugins:docker-compose-maven-plugin:1.0.1:down

./gradlew clean build composeUp
http :8080/app/
http :9990/console/index.html
./gradlew composeDown

links:

generated by daggerok-fatjar yeoman generator