CHAPTER 6: Component-Based Web Development Using JSF 2 291
- org.springframework.web.context.ContextLoaderListener
- org.springframework.web.context.request.RequestContextListener
Line 33 to 37: Configures ContextLoaderListener
Line 38 to 42: Configures RequestContextListener
SpringBeanFacesELResolver is an ELResolver implementation that delegates to Spring’s
WebApplicationContext and the default resolver of the underlying JSF implementation. Listing 6-19
illustrates adding the el-resolver.
Listing 6-19. faces-config.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <faces-config
- 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-facesconfig_2_0.xsd" - version="2.0">
- org.springframework.web.jsf.el.SpringBeanFacesELResolver
Lines 7 to 11: Configures Spring EL resolver
JSF is now integrated with the Spring Framework, and you should be able to access the database
via Spring JDBCTemplate.
Accessing a Database from the Web Layer via Spring JDBCTemplate
Next you will create the managed bean to access the database from the web layer. You already
created the Spring JDBCTemplate in Chapter 5. The managed bean you are going to create now will
use the JDBCTemplate created earlier via the BookService, which was also created in Chapter 5. In
other words, we will create the managed bean to access the database via the service layer and data
access layer created in Chapter 5. Listing 6-20 illustrates the BookController managed bean.