Java Reference
In-Depth Information
Integrating JSF with Spring Framework
To integrate JSF with the Spring dependency injection framework, you have to do the following:
ContextLoaderListener and RequestContextListener listeners provided
by the Spring Framework in web.xml
Add an
Add the
el-resolver entry in faces-config.xml to point to the Spring class
SpringBeansFacesELResolver
Listing 6-18 illustrates adding ContextLoaderListener and RequestContextListener in the
web.xml file.
Listing 6-18. web.xml
1. <?xml version="1.0" encoding="UTF-8"?>
2. <web-app xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance " xmlns=" http://java.sun.com/xml/
ns/javaee " xmlns:web=" http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd " xsi:schemaLocation=" http://
java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd " metadata-
complete="true" version="3.0">
3. <display-name>JSFBooks</display-name>
4. <servlet>
5. <servlet-name>Faces Servlet</servlet-name>
6. <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
7. <load-on-startup>1</load-on-startup>
8. </servlet>
9. <servlet-mapping>
10. <servlet-name>Faces Servlet</servlet-name>
11. <url-pattern>/faces/*</url-pattern>
12. </servlet-mapping>
13. <servlet-mapping>
14. <servlet-name>Faces Servlet</servlet-name>
15. <url-pattern>*.jsf</url-pattern>
16. </servlet-mapping>
17. <servlet-mapping>
18. <servlet-name>Faces Servlet</servlet-name>
19. <url-pattern>*.faces</url-pattern>
20. </servlet-mapping>
21. <context-param>
22. <description>State saving method: 'client' or 'server' (=default). See JSF Specification
2.5.2</description>
23. <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
24. <param-value>client</param-value>
25. </context-param>
26. <context-param>
27. <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
28. <param-value>resources.application</param-value>
29. </context-param>
30. <listener>
31. <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
32. </listener>
 
Search WWH ::




Custom Search