Java EE 5 SDK

javax.faces.validator
Interface Validator

All Superinterfaces:
EventListener
All Known Implementing Classes:
DoubleRangeValidator, LengthValidator, LongRangeValidator, MethodExpressionValidator

public interface Validator
extends EventListener

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

Individual Validators should examine the value and component that they are passed, and throw a ValidatorException containing a FacesMessage, documenting any failures to conform to the required rules.

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.

Validator implementations must have a zero-arguments public constructor. In addition, if the Validator class wishes to have configuration property values saved and restored with the view, the implementation must also implement StateHolder.


Field Summary
static String NOT_IN_RANGE_MESSAGE_ID
          Deprecated. Use DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID or LongRangeValidator.NOT_IN_RANGE_MESSAGE_ID instead.
 
Method Summary
 void validate(FacesContext context, UIComponent component, Object value)
          Perform the correctness checks implemented by this Validator against the specified UIComponent.
 

Field Detail

NOT_IN_RANGE_MESSAGE_ID

static final String NOT_IN_RANGE_MESSAGE_ID
Deprecated. Use DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID or LongRangeValidator.NOT_IN_RANGE_MESSAGE_ID instead.

The message identifier of the FacesMessage to be created if the maximum or minimum value check fails, and both the maximum and minimum values for this validator have been set. The message format string for this message may optionally include a {0} placeholder, which will be replaced by the configured minimum value, and a {1} placeholder, which will be replaced by the configured maximum value.

See Also:
Constant Field Values
Method Detail

validate

void validate(FacesContext context,
              UIComponent component,
              Object value)
              throws ValidatorException

Perform the correctness checks implemented by this Validator against the specified UIComponent. If any violations are found, a ValidatorException will be thrown containing the FacesMessage describing the failure.

Parameters:
context - FacesContext for the request we are processing
component - UIComponent we are checking for correctness
value - the value to validate
Throws:
ValidatorException - if validation fails
NullPointerException - if context or component is null

Java EE 5 SDK

Submit a bug or feature

Copyright 2006 Sun Microsystems, Inc. All rights reserved.