javax.faces.validator
Interface Validator

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
javax.faces.validator.ValidatorBase

public interface Validator
extends java.io.Serializable

A Validator implementation is a class that can perform validation (correctness checks) on a UIComponent. Zero or more Validators can be associated with each UIComponent in the component tree, and are called during the Process Validations phase of the request processing lifecycle.

Individual Validators should examine the component that they are passed, and add Message instances to the FacesContext for the current request, documenting any failures to conform to the required rules. In general, such messages should be associated with the UIComponent on which the validation failure occurred. In addition, the valid property of the corresponding UIComponent should be set to false on validation failures.

For maximum generality, Validator instances may be configurable based on properties of the Validator implementation class. For example, a range check Validator might support configuration of the minimum and maximum values to be used. In addition, because Validators are part of the saved and restored state of a component tree, classes that implement this interface must also be serializable.


Method Summary
 void validate(FacesContext context, UIComponent component)
          Perform the correctness checks implemented by this Validator against the specified UIComponent.
 

Method Detail

validate

public void validate(FacesContext context,
                     UIComponent component)

Perform the correctness checks implemented by this Validator against the specified UIComponent. If any violations are found:

Parameters:
context - FacesContext for the request we are processing
component - UIComponent we are checking for correctness
Throws:
java.lang.NullPointerException - if context or component is null