Advanced Java (2160707)

BE | Semester-4   Winter-2018 | 20-11-2018

Q5) (c)

Draw the JSF request processing life cycle and briefly give the function of each phase.

  • JSF application lifecycle consist of six phases which are as follows:
    1. Phase-I: Restore View (RV)
    2. Phase-II: Apply Request Values (ARV)
    3. Phase-III: Process Validations (PV)
    4. Phase-IV: Update Model Values (UMV)
    5. Phase-V: Invoke Application (IA)
    6. Phase-VI: Render Response (RR)
JSF Application Life-cycle
(Figure: JSF Application Life-cycle)

Phase 1: Restore view

  • JSF begins the restore view phase as soon as a link or a button is clicked and JSF receives a request.
  • During this phase, the JSF builds the view, wires event handlers and validators to UI components and saves the view in the FacesContext instance.
  • The FacesContext instance will now contains all the information required to process a request

Phase 2: Apply request values

  • In this phase, the values that are entered by the user will be updated on each and every individual component defined in the View graph.
  • Component stores this value.
  • If any of the Conversions or the Validations fail, then the current processing is terminated and the control directly goes to the Render Response for rendering the conversion or the validation errors to the Client.

Phase 3: Process validation

  • This Phase will process any Validations that are configured for UI Components.
  • These validations will only happen for the UI Components only if the property 'rendered' property is set to 'true'.

Phase 4: Update model values

  • After the JSF checks that the data is valid, it walks over the component tree and set the corresponding server-side object properties to the component’s local values.
  • The JSF will update the bean properties corresponding to input component's value attribute.

Phase 5: Invoke application

  • During this phase, the JSF handles any application-level events, such as submitting a form / linking to another page.
  • In this phase, JSF Implementation will call the UIComponentBase.processApplications() method which will immediately call the Render Response Phase.

Phase 6: Render response

  • And finally, we have reached the Render Response whose job is to render the response back the Client Application.