javax.faces.validator
Class RequiredValidator

java.lang.Object
  extended byjavax.faces.validator.ValidatorBase
      extended byjavax.faces.validator.RequiredValidator
All Implemented Interfaces:
java.io.Serializable, Validator

public class RequiredValidator
extends javax.faces.validator.ValidatorBase

RequiredValidator is a Validator that checks for the existence of a value for the associated component. For the purposes of this Validator, existence means a non-null value returned by calling getValue(). In addition, if the component value is a String, it must have a length greater than zero.

See Also:
Serialized Form

Field Summary
static java.lang.String FAILED_MESSAGE_ID
          The message identifier of the Message to be created if this validation fails.
 
Constructor Summary
RequiredValidator()
           
 
Method Summary
protected  double doubleValue(java.lang.Object attributeValue)
          Return the specified attribute value, converted to a double.
protected  Message getMessage(FacesContext context, java.lang.String messageId)
          Return a Message for the specified parameters.
protected  Message getMessage(FacesContext context, java.lang.String messageId, java.lang.Object[] params)
          Return a Message for the specified parameters.
protected  MessageResources getMessageResources()
          Return the MessageResources instance for the message resources defined by the JavaServer Faces Specification.
protected  long longValue(java.lang.Object attributeValue)
          Return the specified attribute value, converted to a long.
protected  java.lang.String stringValue(java.lang.Object attributeValue)
          Return the specified attribute value, converted to a String.
 void validate(FacesContext context, UIComponent component)
          Perform the correctness checks implemented by this Validator against the specified UIComponent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FAILED_MESSAGE_ID

public static final java.lang.String FAILED_MESSAGE_ID

The message identifier of the Message to be created if this validation fails.

See Also:
Constant Field Values
Constructor Detail

RequiredValidator

public RequiredValidator()
Method Detail

validate

public void validate(FacesContext context,
                     UIComponent component)
Description copied from interface: Validator

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


getMessage

protected Message getMessage(FacesContext context,
                             java.lang.String messageId)

Return a Message for the specified parameters.

Parameters:
context - The FacesContext associated with the request being processed
messageId - Message identifier of the requested message

getMessage

protected Message getMessage(FacesContext context,
                             java.lang.String messageId,
                             java.lang.Object[] params)

Return a Message for the specified parameters.

Parameters:
context - The FacesContext associated with the request being processed
messageId - Message identifier of the requested message
params - Substitution parameters for this message

getMessageResources

protected MessageResources getMessageResources()

Return the MessageResources instance for the message resources defined by the JavaServer Faces Specification.


doubleValue

protected double doubleValue(java.lang.Object attributeValue)
                      throws java.lang.NumberFormatException

Return the specified attribute value, converted to a double.

Parameters:
attributeValue - The attribute value to be converted
Throws:
java.lang.NumberFormatException - if conversion is not possible

longValue

protected long longValue(java.lang.Object attributeValue)
                  throws java.lang.NumberFormatException

Return the specified attribute value, converted to a long.

Parameters:
attributeValue - The attribute value to be converted
Throws:
java.lang.NumberFormatException - if conversion is not possible

stringValue

protected java.lang.String stringValue(java.lang.Object attributeValue)

Return the specified attribute value, converted to a String.

Parameters:
attributeValue - The attribute value to be converted