background image

JavaServer Faces Implementation

<< The Life Cycle of a JavaServer Faces Page | Restore View Phase >>
<< The Life Cycle of a JavaServer Faces Page | Restore View Phase >>

JavaServer Faces Implementation

The JavaServer Faces implementation performs all these tasks as a series of steps in the
JavaServer Faces request-response life cycle.
Figure 10­3
illustrates these steps.
The life cycle handles both kinds of requests: initial requests and postbacks. When a user makes
an initial request for a page, he or she is requesting the page for the first time. When a user
executes a postback, he or she submits the form contained on a page that was previously loaded
into the browser as a result of executing an initial request. When the life cycle handles an initial
request, it only executes the restore view and render response phases because there is no user
input or actions to process. Conversely, when the life cycle handles a postback, it executes all of
the phases.
Usually, the first request for a JavaServer Faces pages comes in as a result of clicking a hyperlink
on an HTML page that links to the JavaServer Faces page. To render a response that is another
JavaServer Faces page, the application creates a new view and stores it in the FacesContext
instance, which represents all of the contextual information associated with processing an
incoming request and creating a response. The application then acquires object references
needed by the view and calls FacesContext.renderResponse, which forces immediate
rendering of the view by skipping to the
"Render Response Phase" on page 318
of the life cycle,
as is shown by the arrows labelled Render Response in the diagram.
Sometimes, an application might need to redirect to a different web application resource, such
as a web service, or generate a response that does not contain JavaServer Faces components. In
these situations, the developer must skip the rendering phase (
"Render Response Phase" on
page 318
) by calling FacesContext.responseComplete. This situation is also shown in the
diagram, this time with the arrows labelled Response Complete.
Restore
View
Apply
Requests
Process
Events
Process
Validations
Process
Events
Update
Model
Values
Process
Events
Invoke
Application
Process
Events
Render
Response
Faces
Request
Response
Complete
Response
Complete
Response
Complete
Response
Complete
Render
Response
Conversion Errors/
Render Response
Validation/
Conversion Errors/
Render Response
Faces
Response
FIGURE 10­3
JavaServer Faces Standard Request-Response Life Cycle
The Life Cycle of a JavaServer Faces Page
The Java EE 5 Tutorial · September 2007
314