background image

Validation Model

<< Data-Model Events | The Guess Number Example >>
<< Data-Model Events | The Guess Number Example >>

Validation Model

Validation Model
JavaServer Faces technology supports a mechanism for validating the local data of editable
components (such as text fields). This validation occurs before the corresponding model data is
updated to match the local value.
Like the conversion model, the validation model defines a set of standard classes for performing
common data validation checks. The JavaServer Faces core tag library also defines a set of tags
that correspond to the standard Validator implementations. See
Table 11­7
for a list of all the
standard validation classes and corresponding tags.
Most of the tags have a set of attributes for configuring the validator's properties, such as the
minimum and maximum allowable values for the component's data. The page author registers
the validator on a component by nesting the validator's tag within the component's tag.
The validation model also allows you to create your own custom validator and corresponding
tag to perform custom validation. The validation model provides two ways to implement
custom validation:
Implement a Validator interface that performs the validation. See
"Implementing the
Validator Interface" on page 399
for more information.
Implement a backing bean method that performs the validation. See
"Writing a Method to
Perform Validation" on page 406
for more information.
If you are implementing a Validator interface, you must also:
Register the Validator implementation with the application. See
"Registering a Custom
Validator" on page 450
for more information.
Create a custom tag or use a validator tag to register the validator on the component. See
"Creating a Custom Tag" on page 402
for more information.
If you are implementing a backing bean method to perform validation, you also must reference
the validator from the component tag's validator attribute. See
"Referencing a Method That
Performs Validation" on page 372
for more information.
Navigation Model
The JavaServer Faces navigation model makes it easy to define page navigation and to handle
any additional processing needed to choose the sequence in which pages are loaded.
As defined by JavaServer Faces technology, navigation is a set of rules for choosing the next page
to be displayed after a button or hyperlink is clicked. These rules are defined by the application
architect in the application configuration resource file (see
"Application Configuration
Resource File" on page 437
) using a small set of XML elements.
Navigation Model
Chapter 10 · JavaServer Faces Technology
307