The Lifecycle of JSF Faces

JSF

Restore view

Restore view is the first stage of the JSF life cycle. If it is the first attempt to visit the site, only this stage and render response will occur. The restore view phase will create a restorable view in the FacesContext instance to be used for subsequent calls. Upon other action events, or postbacks, the restore view will again be executed. The restore view will use any available and applicable contexts to populate the view and component tree that responds to the postback [3].

Apply request values

Calls other than the initial call will proceed with all stages of the life cycle. In phase 2, all components refresh their values via local(provided) decode methods. Any values that fail to update will produce errors shown in the render response phase. After this process, is complete, the application can complete the forward associated with its action event [3].

Process validation

After the values are updated, they are compared with guidelines set in registered validator instances. This can also be handled in component classes if necessary. Any failed validations will also produce error codes and the messages from phase 2 and 3 are delivered to the FacesContext instance for the request. When failures are present in phase 2 or phase 3, phase 3 returns control to the render response phase for communication. If no errors in applying or validating the data occurred, the next phase begins [2].

Update model values

Reaching this state implies that values are valid, the component tree is correct, and updates can be made to reflect the calling request. JSF will update the backingBean attributes that match a components value attribute. After this phase is complete, internal queued events will be alerted and allowed to begin [3]

Invoke application

In phase 5, the application logic takes place. If the user is submitting a form, whatever redirect programmed to occur can be executed. After invocation, control moves to the render response phase [3].

Render response

If the occurrence is an initial request, the page will be displayed and initial components are added to the tree. On subsequent requests, the components are already present and ‘wired’, so the view is displayed with updated information and saved in the FacesContext for further use [3].

 

Sources

[1] https://www.tutorialspoint.com/jsf/jsf_life_cycle.htm

[2] https://www.ibm.com/docs/en/radfws/9.7?topic=overview-javaserver-faces-life-cycle

[3] https://docs.oracle.com/javaee/7/tutorial/jsf-intro006.htm

[4] https://www.geeksforgeeks.org/jsf-lifecycle-execute-and-render-stage/

Previous
Previous

Java Review: Sets & Maps

Next
Next

What are JSF Facelets?