JSF Phases

The notion of “phases” of action is an important concept in JSF. When a form button is submitted, there are a set of “phases” that happen, one after another, until a response is rendered. This handles the case of “post a form”; the other cases (such as simple page display) have simpler phases.

  1. First, a request comes in. If the request includes a JSF “view state” (because, presumably, state was persisted to the client in a previous display of a page), then the view state is restored to the backing bean.
  2. Next, request values (from the form) are written to fields of the backing bean, according to the value expressions specified in the JSP or XHTML file.
    1. Obviously, JSF converters are invoked at this stage to convert, say, a string representation of a date to a Java Date object.
  3. Next, any validations that have been specified are invoked, and error messages from the validators are recorded in the FacesContext.
    1. If any validations fail, then we jump to the “Render response” phase.
  4. After validations, we bind component values to the backing bean properties.
  5. Next, the application methods bound to the form button is invoked (say, to save an object in a database, or execute a search).
  6. Lastly, the response is rendered by JSF, and the page is written.

Some Writings on Phase Listeners

It's only fair to share...
Share on Facebook
Tweet about this on Twitter
Share on LinkedIn

Leave a Reply