Learn Java for Web Development

(Tina Meador) #1

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


The Architecture of JSF


A JSF web framework uses the Model-View-Controller (MVC) design pattern like request-based web
frameworks such as Struts and SpringMVC do. Figure 6-1 shows a high-level architecture of the JSF
framework.


Controller

FacesServlet

delegated
Renderer

Converter

Validator

request

response
direct

View

Client

Model

Managed
bean

UI Component
VDL
JSF EL
JSF tag libraries

Figure 6-1. A high-level architecture of the JSF framework


Figure 6-1 presents several important parts of JSF that make its architecture rich and flexible.
This architecture allows you to do the following:


   Plug in any view declaration language (VDL) such as JSP and Facelets
 Render the display in different devices, such as desktops, tablets, and so on
 Create pages using components

FacesServlet

FacesServlet is the controller in the MVC, as shown in Figure 6-1, and implements the Front
Controller pattern that intercepts every interaction between Facelets (the view) and the model.
FacesServlet is configured through annotations on managed beans, converters, components,
renderers, and validators or optionally through the faces-config.xml descriptor file.


Managed Bean

Managed beans serve as the model for the UI component. They are responsible for the following:


   Synchronizing data with components
 Processing business logic
 Handling navigation between pages
Free download pdf