Structure of a JSF Application
JSF applications are web applications built on the Java Servlet framework, so they follow the same general packaging scheme as any other J2EE application (see Chapter 2 for more information). The jar files for the JSF implementation must be available on the web application’s classpath (usually accomplished by putting the appropriate jar files into the WEB-INF/lib directory).
For the reference implementation, the FacesServlet must be configured in the
web.xml file for the application. This servlet
provides the JSF engine: it’s responsible for processing requests for
JSF-based pages and returning the UI in HTML format. For our example,
we’re going to treat all resources with a .faces
extension as a JSF target, so we configure the FacesServlet like this:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>Mapping *.faces to the FacesServlet instructs the servlet container
to delegate all requests ending with .faces to
the JSF engine.
JSF Lifecycle
So what happens when a request is sent to the JSF engine? In short, the JSF engine creates a tree containing a set of “components,” each corresponding to an element of the user interface for the page being submitted, and ensures that the correct user values are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access