What is Restore View Phase in JSF LifeCycle?

RestoreView is the first phase in the JSF lifecycle. This phase is used for constructing view to display in 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. There is two types of state saving mechanism,

1)Server
2)Client

Default value is server. If you specify state saving method as server, the state of each components will be stored in the server. If it is client, it will be stored in the client side as hidden variables. This value is configured in web.xml as follows:


<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

Next we will see how FacesServelt construct the view. FacesServlet is the controller servlet in JSF where all the requests will be redirected. when first time JSP page is accessed, FacesServlet will look for whether the view is already exist. If the requested view doesn't exist, then it will create the new view(here creating view means saving the state of all components and store it in the FacesContext) and send the response. When the same JSP is accessed second time, FacesServlet will use the existing view and apply the new request values(apply request values is another phase in the lifecycle) to all the components.

PAGE scope means a hashmap that is stored in the JSF ViewRoot, it's for a particular page, for a particular user (even bound to request/response cycles), and it's not stateless.

你可能感兴趣的:(jsp,Web,xml,servlet,JSF)