Java Reference
In-Depth Information
LISTING 14-4 (continued)
<title>List of users</title>
< h1 > Our users are: < /h1 >
< c:forEach items="${requestScope.listusers}" var="listusers" >
< br > ${listusers}
< /c:forEach >
The example that's been demonstrated is a simple implementation of the MVC pattern. You'll continue
by looking at how you would implement the same application but using the advantages of Java EE 7.
The plain code implementation of the MVC pattern required you to write the controller logic, map
the URLs to controller classes, and write a lot of plumbing code. However, in the latest release of
Java EE, the plumbing code has been done for you. You only need to concentrate on the view and
the model. The FacesServlet takes care of the controller implementation.
The FacesServlet takes control of managing user requests and delivering the view to the user. It
manages the life cycle for web applications that use JSF to construct the user interface. All user requests
go through the FacesServlet. The servlet is integral to JSF and can be coni gured if nonconventional
behavior is required. However, thanks to the concept of convention over coni guration, you will i nd that
for all but the most complex web applications, it is not necessary to change the default coni gurations.
If you do need to change the FacesServlet coni guration, you must amend the
faces‐config.xml i le.
Since JSF 2.2, you can perform the most common coni gurations by using annotation, further
reducing the need to touch the faces‐config.xml i le.
You are going to rewrite the preceding example using the FacesServlet servlet and JSF. The view
declaration language for JSF is called facelets. Facelets are the replacement for JSPs and are written
in XHTML using cascading style sheets (CSS).
JSF includes the concept of backing beans. These are Plain Old Java Objects (POJOs)
annotated with the @Named and the @RequestScope annotations. These beans are accessible by the
Search WWH ::

Custom Search