com.ibm.xsp.validator
Class AbstractValidator

java.lang.Object
  extended by com.ibm.xsp.complex.ValueBindingObjectImpl
      extended by com.ibm.xsp.validator.AbstractValidator
All Implemented Interfaces:
ComponentBindingObject, ValueBindingObject, java.util.EventListener, javax.faces.component.StateHolder, javax.faces.validator.Validator
Direct Known Subclasses:
ConstraintValidator, DateTimeRangeValidator, ExpressionValidator, ModulusSelfCheckValidator, RequiredValidator, ValidatorMethodBinding

public abstract class AbstractValidator
extends ValueBindingObjectImpl
implements javax.faces.validator.Validator

Useful superclass for server-side validators. If client-side validation is also required, subclasses should implement ClientSideValidator.


Field Summary
 
Fields inherited from interface javax.faces.validator.Validator
NOT_IN_RANGE_MESSAGE_ID
 
Constructor Summary
AbstractValidator()
           
 
Method Summary
protected  void addInputInvalidMessage(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.application.FacesMessage.Severity severity, java.lang.String message)
          A utility available to be called in subclasses.
static java.lang.NullPointerException createNullContextOrComponentEx()
          Utility method available to validators, to create an exception for when either of first 2 arguments to Validator.validate(FacesContext, UIComponent, Object) is null.
static javax.faces.validator.ValidatorException createValidatorEx(java.lang.String msg)
          Util to create a ValidatorException with severity level "error", and the given message.
static java.lang.String getInvalidRangeMessage(boolean minSet, java.lang.String minStr, boolean maxSet, java.lang.String maxStr)
          Util giving an range error message, to use if the user has not configured their own error message.
 java.lang.String getMessage()
          Returns the validation error message to be displayed to user
static java.lang.String getNotCorrectTypeMessage()
          Util error message complaining the value is not of the correct type.
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setMessage(java.lang.String message)
          Sets the validation error message to be displayed to the user
 
Methods inherited from class com.ibm.xsp.complex.ValueBindingObjectImpl
getComponent, getFacesContext, getValueBinding, isTransient, setComponent, setTransient, setValueBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.validator.Validator
validate
 

Constructor Detail

AbstractValidator

public AbstractValidator()
Method Detail

addInputInvalidMessage

protected void addInputInvalidMessage(javax.faces.context.FacesContext context,
                                      javax.faces.component.UIComponent component,
                                      javax.faces.application.FacesMessage.Severity severity,
                                      java.lang.String message)
A utility available to be called in subclasses. Adds a FacesMessage with the given message, and calls UIInput.setValid(boolean) false.

Parameters:
context -
component -
severity -
message -

getMessage

public java.lang.String getMessage()
Returns the validation error message to be displayed to user

Returns:
validation error message

setMessage

public void setMessage(java.lang.String message)
Sets the validation error message to be displayed to the user


saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class ValueBindingObjectImpl

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class ValueBindingObjectImpl

getNotCorrectTypeMessage

public static java.lang.String getNotCorrectTypeMessage()
Util error message complaining the value is not of the correct type.

Returns:
Not correct type message

createValidatorEx

public static javax.faces.validator.ValidatorException createValidatorEx(java.lang.String msg)
Util to create a ValidatorException with severity level "error", and the given message.

Parameters:
msg -
Returns:
validator exception

getInvalidRangeMessage

public static java.lang.String getInvalidRangeMessage(boolean minSet,
                                                      java.lang.String minStr,
                                                      boolean maxSet,
                                                      java.lang.String maxStr)
Util giving an range error message, to use if the user has not configured their own error message. Chooses from 3 possible messages depending on minSet, maxSet or both set.

Parameters:
minSet -
minStr -
maxSet -
maxStr -
Returns:
Invalid Range Message

createNullContextOrComponentEx

public static java.lang.NullPointerException createNullContextOrComponentEx()
Utility method available to validators, to create an exception for when either of first 2 arguments to Validator.validate(FacesContext, UIComponent, Object) is null.

Returns:
null pointer exception