HTML and CSS Reference
In-Depth Information
the “apply request Values” is applied to all the components which have a value attribute. In JSF, the
components which have the value attribute must implement the ValueHolder interface. In order to apply the request
values to all the value holder nodes in the uI components tree, the JSF runtime calls the processDecodes() method of
the UIViewRoot , which causes the child components' processDecodes() method to be called as well in order to apply
the request values for all of them.
Note
Process Validations
The “Process Validations” phase is called after the “Apply Request Values” phase. In this phase, the conversion and the
validation are performed in order. In the favorites.xhtml , a validation is performed on all the input fields in order to
guarantee that they will always have non-empty values by setting the "required" attribute to true .
Conversion is about converting the HTTP request parameters to the corresponding Java types in order to eliminate
the overhead required from the developer to implement this functionality for every web application. JSF has many
built-in converters and it provides an interface in order to develop custom converters. Listing 1-12 shows an example of
the JSF built-in date converter.
Listing 1-12. An Example of the Built-in Date Converter
<h:inputText id="birthDate" value="#{user.birthDate}">
<f:convertDateTime pattern="dd/MM/yyyy"/>
</h:inputText>
In this example, the "birthDate" input field is ensured to have a date with the following format "dd/MM/yyyy"
and is converted to the birthDate ( Date object) property in the User managed bean (more details of validations and
conversions will be illustrated in Chapter 3).
When a component has a failing validation (or conversion), the component error message ( FacesMessage )
will be queued in the FacesContext instance. In case of validation (or conversion) errors, the JSF lifecycle directly
proceeds to the “Render Response” phase, and the queued Faces messages will be displayed in the <h:message> or
<h:messages> UI components.
In order to apply the process validations in the uI components tree, the JSF runtime calls the processValidators()
method of the UIViewRoot , which causes the child components' processValidators() method to be called as well in order to
apply the conversion and the validation to all of them.
Note
Update Model Values
The “Update Model Values” phase is called after completing the conversion and the validation of the values in the UI
components tree. In this phase, the binding is done between the values in the UI components tree and the JSF model
(managed beans).
Figure 1-10 shows how the JSF managed bean properties are updated with the values of the UI components tree.
 
 
Search WWH ::




Custom Search