servlets struts hibernate spring maven java
 

JavaServer Faces Lifecycle



JavaServer Faces application framework oversees lifecycle phases naturally for simple applications and furthermore enables you to manage with that manually. The lifecycle of a JavaServer Faces application starts when the client makes a HTTP request for a page and finishes when the server responds with the page.

The JSF lifecycle is divided into two main phases:
  1. Execute Phase
  2. Render Phase

1) Execute Phase

In execute phase, when first request is made, application view is built or restored. For other resulting requests different activities are performed like request parameter values are connected, changes and approvals are performed for component values, managed beans are refreshed with component values and application rationale is invoked.

The execute phase is additionally separated into following subphases.

  • Restore View Phase
  • Apply Request Values Phase
  • Process Validations Phase
  • Update Model Values Phase
  • Invoke Application Phase
  • Render Response Phase

Restore View Phase

When a client requests for a JavaServer Faces page, the JavaServer Faces usage starts the reestablish view method. In this method, JSF fabricates the perspective on the mentioned page, wires occasion handlers and validators to components in the view and spares the view in the FacesContext instance.

If the current for the page is a postback, a view relating to this page as of now exists in the FacesContext occurrence. During this method, the JavaServer Faces execution reestablishes the view by utilizing the state data saved money on the client or the server.

Apply Request Values Phase

In this method, component tree is reestablished during a postback demand. component tree is an accumulation of framework elements.Each component in the tree extricates its new incentive from the current parameters by utilizing its interpret (processDecodes()) method. After that value is put away locally on each component.

  • If any translate strategies or occasion audience members have called the renderResponse method on the current FacesContext occurrence, the JavaServer Faces execution jumps to the Render Response phase.
  • If any events have been lined during this method, the JavaServer Faces execution communicates the events to intrigued listeners.
  • If the application needs to divert to an alternate web application asset or create a reaction that does not contain any JavaServer Faces components, it can call the FacesContext.responseComplete() method.
  • If the present current is recognized as an incomplete request , the halfway setting is recovered from the FacesContext, and the fractional preparing method is applied.

Process Validations Phase

In this method, the JavaServer Faces forms all validators enrolled on the components by utilizing its approve () method . It looks at the component traits that indicate the guidelines for the approval and thinks about these principles to the local value put away for the component. The JavaServer Faces additionally finishes changes for info components that don't have the prompt credit set to true.

  • If any approve methods or occasion audience members have called the renderResponse method on the current FacesContext, the JavaServer Faces usage jumps to the Render Response phase.
  • If the application needs to divert to an alternate web application asset or produce a reaction that does not contain any JavaServer Faces components, it can call the FacesContext.responseComplete method.
  • If events have been lined during this method, the JavaServer Faces execution communicates them to intrigued listeners.
  • If the present current is identified as a halfway request , the fractional setting is recovered from the FacesContext, and the incomplete handling method is applied.
  • Update Model Values Phase

    After ensuring that the input is traverses, it navigates the component tree and sets the relating server-side article properties to the components' local values. The JavaServer Faces usage refreshes just the bean properties pointed at by an input component's value quality. On the off chance that the neighborhood input can't be changed over to the sorts indicated by the bean properties, the lifecycle progresses traversesly to the Render Response method so the page is re-rendered with errors displayed.

    • If any updateModels methods or any audience members have called the renderResponse() strategy on the current FacesContext occasion, the JavaServer Faces execution jumps to the Render Response phase.
    • If the application needs to divert to an alternate web application asset or create a reaction that does not contain any JavaServer Faces components, it can call the FacesContext.responseComplete() method.
    • If any events have been lined during this method, the JavaServer Faces execution communicates them to intrigued listeners.
    • If the present request is recognized as a halfway request, the incomplete setting is recovered from the FacesContext, and the fractional preparing method is applied.

    Invoke Application Phase

    In this method, JSF handles application-level events, for example, presenting a framework or connecting to another page.

    Now, if the application needs to divert to an alternate web application asset or produce a reaction that does not contain any JSF components, it can call the FacesContext.responseComplete() method.

    After that, the JavaServer Faces usage moves control to the Render Response phase.

    Render Response Phase

    This is last period of JSF life cycle. In this method, JSF fabricates the view and delegates specialist to the fitting asset for rendering the pages.

    • If this is an underlying request, the components that are represented to on the page will be added to the component tree.
    • If this isn't an underlying request, the components are as of now added to the tree and need not to be included again.
    • If the request is a postback and errors were experienced during the Apply Request Values method, Process Validations method, or Update Model Values method, the first page is rendered again during this method.
    • If the pages contain h:message or h:messages labels, any lined mistake messages are shown on the page.
    • After rendering the substance of the view, the condition of the reaction is saved so resulting requests can get to it. The saved state is accessible to the Restore View phase.

    2) Render

    In this method, the mentioned view is rendered as a reaction to the client program. View rendering is a procedure wherein yield is created as HTML or XHTML. Along these lines, client can see it at the browser.

    The following advances are taken during the render process.

    • Application is arranged, when a client makes an underlying request for the index.xhtml web page.
    • Application executes after gathering and another component tree is developed for the application and set in a FacesContext.
    • The component tree is populated with the component and the managed bean property related with it, represented to by the EL expression.
    • Based on the component tree. Another view is built.
    • The view is rendered to the requesting client as a response.
    • The component tree is destroyed automatically.
    • On resulting requests, the component tree is remade, and the saved state is applied.






© Javacodegeeks © 2019 - 2019
All Right Reserved and you agree to have read and accepted our term and condition.

Python 3