JAVAEE Week 6

JSF  life cycle:
FacesServlet acts as the link between the user and the JSF application. It works within the confines of a well-defined  JSF  lifecycle that dictates the entire flow of events between user requests.
1. When an event occurs on a JSF page (eg the user clicks a button), the event notification is sent to the server via HTTP. The server uses a special servlet, FacesServet, to handle the notification.
2. FacesServlet creates a FacesContext object (JSF context, which stores all the data of the application) as soon as it receives the user's request. In the processing process, the main modification is the FaceContext object.
3. Then there is the process, the processor is an object called Lifecycle. FacesServet transfers control to the Lifecycle object. This object processes the FacesContext object in 6 stages to generate the response and finally sends the response back to the client.
The series of actions required by the Lifecycle object to process a JSP request is called the request processing life cycle. The process state diagram is as follows:
Since the application request value, processing validation, updating model value, and calling application phases in the request processing lifecycle can add events to the FacesContext instance corresponding to the current request, the JSF implementation must process these events after these phases.
 
stage illustrate
restore view
Find or create a component tree for the selected view.
This phase is initiated as soon as the user clicks a link or button on the JSP page. JSP pages in a JSF application are represented as a tree of components. The JSF implementation further links these components to event handlers and validators, and saves the view in the FacesContext object for later processing. The FacesContext object contains all the state information that JSF needs to manage the state of the GUI components currently requested in the current session.
Apply request value Update the component values ​​of the component tree with the values ​​sent in the request. Because the values ​​sent in the request are all of type String, these values ​​must be converted to the corresponding type before updating the component values ​​of the component tree. This process is also decoding. If there are errors in the conversion, these errors will be added to the FacesContext object.
handle validation
When the local value of each component is updated, the Lifecycle object will verify the validity of these values ​​according to the validation rules of these registered components.
If the entered value does not meet the validation rules, a validation error is added to the FacesContext object and the component is marked as invalid. JSF will go to the render response phase and display the view with the validation error message.
If no validation errors are encountered, JSF will proceed to the next stage.
update model values Updates the value of a component-related backing bean (also called a management bean) or model object. Only those bean properties that are bound with component values ​​will be updated.
call application JSF controllers call applications to handle application-level events, such as submitting a form. (Business logic can be executed at this stage)
render response Displays the selected view using current display technologies such as JSP.

Guess you like

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