JSF 2 Lifecycle
Restore view
RestoreView is the first phase in the JSF lifecycle. Restore view phase is constructing view for the front end. Every view has it's own view id and it is stored in the FacesContext's session object. JSF View is collection of components associated with its current state. In JSF 2 you have two types of saving methods:
- Server (default)
- Client
Server method is set by the default. You can configure it in web.xml as context param using javax.faces.STATE_SAVING_METHOD parameter name:
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
Apply Requests
After restoring the component tree, each component in the tree extracts its new value from the request parameters by using its decode method. After that the value is locally stored in the component. If the conversion of the value fails, an error message associated with the component is generated and queued on FacesContext. This message will be displayed during the render response phase, along with any validation errors resulting from the process validations phase.
Process Validations
In Process Validations phase JavaServer Faces implementation processes all validators registered on the components in the component tree. It examines the component attributes that specify the rules for the validation and compares these rules to the local value stored for the component.
Update Model Values
After JSF validates the data, it can set component tree corresponding server-side object properties to the components' local values. The JavaServer Faces implementation will update only the bean properties pointed at by an input component's value attribute.
If it is impossible to covert the local data to the types specified by the bean properties, the life cycle advances directly to the render response phase so that the page is rerendered with errors. Same happens to the validation errors.
Invoke Applications
During Invoke Application phase, the JSF handles any application-level events, such as submitting a form or linking to another page.
At this point, if the application needs to redirect to a different web application resource or generate a response that does not contain any JavaServer Faces components, it can call FacesContext.responseComplete.
Render Response
During Render Response phase, JavaServer Faces gives authority for rendering the page to the JSP container if the application is using JSP pages. If this is an initial request, the components represented on the page will be added to the component tree as the JSP container executes the page. If this is not an initial request, the components are already added to the tree so they needn't be added again.
Комментариев нет:
Отправить комментарий