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 for more information.
Implement a backing bean method that performs the validation. See Writing a Method to Perform Validation 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 for more information.
Create a custom tag or use a validator tag to register the validator on the component. See Creating a Custom Tag 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 for more information.