278 CHAPTER 6: Component-Based Web Development Using JSF 2
Phase 1: Restore View
JSF begins the Restore View phase as soon as a link or button is clicked and JSF receives a request.
During this phase, JSF does the following:
Builds a component tree from the page. This component tree contains the
information associated with all components of the page. If the page is requested
for the first time, JSF creates an empty view.
Wires event handlers and validators to UI components.
Saves the view in the FacesContext instance.
Phase 2: Apply Request Values
After the component tree is created/restored, the JSF runtime runs the decode method of each
component in the component tree that extracts the values from the request parameters. The values
that are extracted by the decode method are stored in the component, after performing data conversion
if necessary. If the conversion fails, an error message is generated and queued on FacesContext.
Phase 3: Process Validation
During this phase, the JSF runtime processes validators registered on the component tree during the
Restore View phase. If there are validation errors, JSF adds an error message to the FacesContext
instance, skips the fourth and fifth phases, enters the Render Response phase, and displays the
error messages.
Phase 4: Update Model
If there are no validation errors in the Process Validation phase, the JSF runtime updates the
managed bean’s properties that are bound to the UI components with the new values of the UI
components. The conversion is also performed in this phase if necessary.
Request
Render response
on First request
Response
Restore View
Render
Response
Invoke
Application
Apply Request
Value
Update Model
Process
Validation
Figure 6-14. The phases of the JSF life cycle