JSF Lifecycle

2017/02/12 iteye

  The life cycle handles both kinds of requests: initial requests and postbacks. When a user makes an initial request for a page, he or she is requesting the page for the first time. When a user executes a postback, he or she submits the form contained on a page that was previously loaded into the browser as a result of executing an initial request. When the life cycle handles an initial request, it only executes the restore view and render response phases because there is no user input or actions to process. Conversely, when the life cycle handles a postback, it executes all of the phases.  

  1. Restore View
    builds the view root and saves to FacesContext, includes event handlers and validators if it is the initial reqeust, empty view created and life cycle advances to render response directly.
  2. Apply Request Value
    component extracts its new value from the request parameters. Type conversion occurs in this phase.   if renderResponse called on FacesContext, skip to the render response phase.    FacesContext.responseComplete can be called, and redirect to a different web app   if immediate set to true, the validation, conversion,events will be processed in the phase.  
  3. Process Validations
    process validators registered on the components. if any error message, the life cycle advances directly to the render response phase.   if FacesContext.renderResponse called, skip to the render response phase   if FacesContext.responseComplete called, redirect to a different web app  
  4. Update Model value
    update component value to manage bean property   similarily for FacesContext.responseComplete similarily for FacesContext.renderResponse  
  5. Invoke Application
    handle application-level events   similarily for FacesContext.responseComplete
  6. Render Response
    if JSP pages used, the components will render themselves as the JSP container traverses the tags in the page.   if this is the initial request, the components represented on the page will be added to the component tree as the JSP container executes the page.  

Search

    Table of Contents