lifecircle for JSF and Facelets

1. JSF life cycle

1) Restore View (Restore View)

A view represents all the components that make up a particular page. It is saved on the client (usually in a hidden field) or server (usually in the session). According to the view ID (page address) accessed by the request, rebuild the DOM tree of the JSF component. If the JSF page is accessed for the first time, that is, the view ID is not stubbed in memory, then JSF will build the DOM tree of the JSF component in memory. Restoring the view also ensures that the component's value, event listener, validator, or converter associated with the component in the tree, is restored.

2) Apply Request Values

The JSF component obtains its own values ​​in the request, including the local value and the submit value. At the same time, the conversion is processed, the conversion is successful, and the local value (submit conversion result) is updated. Of course, the process is not that simple. The JSF processor has its own set of decoding Process.

3) Execute verification

During the validation phase, JSF traverses the component tree and checks each component to see if each component's submitted value is acceptable. Before validation occurs, the submitted value will first be converted by either the converter registered with the component or the default converter. Validation is then performed directly by the component or delegated to one or more other validators. If the user's input is invalid, an error message will be added to the FacesContext, and the component will be indicated as invalid, and then go to the response phase, displaying the current view, indicating the error message.

4) Update model value: If all component local value conversion verification is successful, then JSF will process the associated bean according to EL and update the bean binding value. Here JSF will load the configured background according to EL binding beans.

5) Call the application: call the registered listener, and then execute event-driven to get the next view. The listener can effectively listen to the various data of the UI component at this time, and the event-driven part, that is, the action, can effectively obtain the updated background bean data. Execute your own business logic.

6) Render Response

At this point, the request processing is over, and according to the navigation rules, the response pages are rendered and executed in sequence.

 

 

2. Facelets life cycle

The JSF specification defines the life cycle of a JavaServer Faces application. The following steps describe the process for a Facelets-based application.

  1. The lifecycle is started when the client Faceletsmakes a new request with the created web page. JSF creates a new component tree or javax.faces.component.UIViewRootputs it in FacesContex.

  2. Views can populate components for rendering UIViewRootif available .Facelets

  3. The newly created view is rendered in response to the client.

  4. When rendering, store the state of this view for the next request. Stores the state of input components and form data.

  5. Clients can interact with a view and request another view from a JSF application. At this point, the saved view is restored from the stored state.

  6. Restoring the view goes through the JSF lifecycle again, and if there are no validation issues, and no action is triggered, it will eventually generate a new view or re-render the current view.

  7. If the same view is requested, the stored view is rendered again.

  8. If a new view is required, proceed to step 2 .

  9. Get the new view as a response to the client.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324797263&siteId=291194637
jsf