JSF Lifecycle Notes

Notes from JavaServer Faces 2.0, The Complete Reference.

A page or better a 'Faces View' (to use the JSF terminology) doesn’t consist of text but of components.

javax.faces.component.UIViewRoot
- javax.faces.component.html.HtmlForm
-- javax.faces.component.html.HtmlInputText
-- javax.faces.component.html.HtmlCommandButton

The Request Processing Lifecycle Phases

- Restore View
Restores or creates a server-side Component Tree (Faces View) in memory to represent the UI information from the client.

**** Input Handling ****
- Apply Request Values
Updates the server-side components with fresh data from the client. The submitted value is stored as String.

- Process Validations
The submitted value is converted to the expected type. Validations are executed. If a conversion or a validation fails, jump to "Render Response".

- Update Model Values
Update server-side model objects.
**** Input Handling ****

- Invoke Application
Invoke the action.

- Render Response
Save state and render response to the client.

Phase: Restore View
Faces View is a server-side tree of the UI components that provides a mirror representation of the user interface presented in a client.
Restore View either restores an existing View from a previous transaction or create a fresh one.
The View is stored in a parent container known as FacesContext. The FacesContext serves as storage for all of the data pertinent

Phase: Apply Request Values
Each UI Component gets updated with the sent values from the client.

Phase: Process Validations
UI components can have converters and validators associated with them. Any component failing conversion or validation will cause a FacesMessage to be queued in FacesContext.

Phase: Update Model Values
Data is bound to the model beans.

Phase: Invoke Application
The called action (method) is finally executed! Navigation is also handled in this phase.

Phase: Render Response
States of component are stored in this phase. A component can save its state. State includes values of attributes etc. The next request can restore this state. For example, a table component can store the rows, columns and the selected rows.