Learn Java for Web Development

(Tina Meador) #1

290 CHAPTER 6: Component-Based Web Development Using JSF 2


Integrating JSF with Spring Framework

To integrate JSF with the Spring dependency injection framework, you have to do the following:


   Add the ContextLoaderListener and RequestContextListener listeners provided
by the Spring Framework in web.xml
 Add an 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. JSFBooks





  4. Faces Servlet


  5. javax.faces.webapp.FacesServlet


  6. 1








  7. Faces Servlet


  8. /faces/*








  9. Faces Servlet


  10. *.jsf








  11. Faces Servlet


  12. *.faces








  13. State saving method: 'client' or 'server' (=default). See JSF Specification
    2.5.2



  14. javax.faces.STATE_SAVING_METHOD


  15. client








  16. javax.servlet.jsp.jstl.fmt.localizationContext


  17. resources.application








  18. com.sun.faces.config.ConfigureListener




Free download pdf