The JSF servlet builds the view of the requested page as a component tree that contains the information associated with all components. It also saves the view in a FacesContext instance, thereby making it possible to repopulate the page if necessaryófor example, when the user doesnít fill out a form as required. If the same page was displayed before and component states were saved, that information would also be taken into account. In this phase, JSF wires event handlers and validators (if any) to the components.
Apply Request Values
The JSF servlet goes through the component tree and executes each componentís decode method, which extracts values from the request parameters and stores them locally in the component. It also automatically converts the parameters that are associated with object properties of non-string types. Conversion errors cause error messages to be queued to the FacesContext object. In some cases, typically when the user clicks on controls, the servlet also generates request events and queues them to FacesContext.
Process Request Events
The servlet calls the processEvent method for each component with one or more queued events. Each component decides to handle the events or delegate their handling to event handlers. In any case, the servlet proceeds with the next phase if all executed processEvent methods return false. Otherwise, it jumps directly to the Render Response phase.
The servlet invokes the validate methods of the validators that had been registered during the Restore View phase. For each validate method that returns false, the servlet queues an error message to the FacesContext.
If validation or conversion errors are generated during the Process Validation phase, control jumps directly to the Render Response phase.
Update Model Values
Each UI component can be linked to a field in a Java object called the model object. During this phase, the values of the linked components are copied to the corresponding fields of the model object by executing the component method updateModel, which also does type conversions when necessary. Conversion errors cause error messages to be queued to FacesContext.
If it turns out that conversion errors were generated during phase 6,control jumps directly to the Render Response phase.
During this phase, the servlet processes the application-level events by executing the corresponding handlers. When the user submits a form or clicks on a link of a JSF application, the JSF servlet generates a corresponding application-level event. One of the tasks you have to do when developing a JSF application is to assign a handler (e.g., a JSP page) to each one of the possible application events.
The servlet creates a response component tree and delegates the rendering of the page to Tomcat. Each component renders itself as Tomcat goes through the corresponding JSF tags. At the end of this phase, the state of the response is saved so that the servlet can access it during the Restore View phase of subsequent requests to the same page.