background image

Process Validations Phase

<< Restore View Phase | Update Model Values Phase >>
<< Restore View Phase | Update Model Values Phase >>

Process Validations Phase

If any decode methods or event listeners called renderResponse on the current FacesContext
instance, the JavaServer Faces implementation skips to the render response phase.
If events have been queued during this phase, the JavaServer Faces implementation broadcasts
the events to interested listeners.
If some components on the page have their immediate attributes (see
"The immediate
Attribute" on page 328
) set to true, then the validation, conversion, and events associated with
these components will be processed during this phase.
At this point, if the application needs to redirect to a different web application resource or
generate a response that does not contain any JavaServer Faces components, it can call
FacesContext.responseComplete
.
At the end of this phase, the components are set to their new values, and messages and events
have been queued.
Process Validations Phase
During this phase, the JavaServer Faces implementation processes all validators registered on
the components in the tree. It examines the component attributes that specify the rules for the
validation and compares these rules to the local value stored for the component.
If the local value is invalid, the JavaServer Faces implementation adds an error message to the
FacesContext
instance, and the life cycle advances directly to the render response phase so that
the page is rendered again with the error messages displayed. If there were conversion errors
from the apply request values phase, the messages for these errors are also displayed.
If any validate methods or event listeners called renderResponse on the current
FacesContext
, the JavaServer Faces implementation skips to the render response phase.
At this point, if the application needs to redirect to a different web application resource or
generate a response that does not contain any JavaServer Faces components, it can call
FacesContext.responseComplete
.
If events have been queued during this phase, the JavaServer Faces implementation broadcasts
them to interested listeners.
In the case of the greeting.jsp page, the JavaServer Faces implementation processes the
standard validator registered on the userNo inputText tag. It verifies that the data the user
entered in the text field is an integer in the range 0 to 10. If the data is invalid or if conversion
errors occurred during the apply request values phase, processing jumps to the render response
phase, during which the greeting.jsp page is rendered again, with the validation and
conversion error messages displayed in the component associated with the message tag.
The Life Cycle of a JavaServer Faces Page
The Java EE 5 Tutorial · September 2007
316