Java Reference
In-Depth Information
Validation Model
JavaServer Faces technology supports a mechanism for validating the local data of ed-
itable 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
javax.faces.validator.Validator implementations. See “Using the Standard
Validators” in The Java EE 6 Tutorial: Basic Concepts for a list of all the standard valid-
ation 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 compon-
ent's tag.
In addition to validators that are registered on the component, you can declare a default
validator which is registered on all UIInput components in the application. For more
information on default validators, see “ Using Default Validators on page 159 .
The validation model also allows you to create your own custom validator and corres-
ponding tag to perform custom validation. The validation model provides two ways to im-
plement custom validation:
• Implement a Validator interface that performs the validation.
• Implement a managed bean method that performs the validation.
If you are implementing a Validator interface, you must also:
• Register the Validator implementation with the application.
• Create a custom tag or use an f:validator tag to register the validator on the
component.
In the previously described standard validation model, the validator is defined for each in-
put component on a page. The Bean Validation model allows the validator to be applied to
all fields in a page. See “Using Bean Validation” in The Java EE 6 Tutorial: Basic Con-
cepts and Chapter 22 , Bean Validation: Advanced Topics , ” for more information on Bean
Validation.
Search WWH ::




Custom Search