org.apache.myfaces.trinidad.validator
Class DateTimeRangeValidator

java.lang.Object
  extended by org.apache.myfaces.trinidad.validator.DateTimeRangeValidator
All Implemented Interfaces:
EventListener, javax.faces.component.StateHolder, javax.faces.validator.Validator

@JSFValidator(configExcluded=true)
public class DateTimeRangeValidator
extends Object
implements javax.faces.validator.Validator, javax.faces.component.StateHolder

DateTimeRangeValidator is a Validator that checks the value of the corresponding component against specified minimum and maximum dates. The following algorithm is implemented:

The detail part of faces message which arise during validation can be customised by overriding the message associated with each message id by calling appropriate setter methods.

The methods used for customizing the detail message associated with each id is given below:

Then this message will be used to construct faces message when validation fails based on the above-mentioned algorithm

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/validator/DateTimeRangeValidator.java#0 $) $Date: 10-nov-2005.19:08:33 $

Field Summary
static String MAXIMUM_MESSAGE_ID
          The message identifier of the FacesMessage to be created if the maximum value check fails.
static String MINIMUM_MESSAGE_ID
          The message identifier of the FacesMessage to be created if the minimum value check fails.
static String NOT_IN_RANGE_MESSAGE_ID
          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.
static String VALIDATOR_ID
           
 
Constructor Summary
DateTimeRangeValidator()
          Construct a Validator with no preconfigured limits.
DateTimeRangeValidator(Date maximum)
          Construct a Validator with the specified preconfigured limit.
DateTimeRangeValidator(Date maximum, Date minimum)
          Construct a Validator with the specified preconfigured limits.
 
Method Summary
 boolean equals(Object o)
           
 String getHintMaximum()
          Return custom hint maximum message.
 String getHintMinimum()
          Return custom hint minimum message.
 String getHintNotInRange()
          Return custom hint notInRange message.
 Date getMaximum()
          Return the maximum value to be enforced by this Validator or null if it has not been set.
 String getMessageDetailMaximum()
          Return custom detail error message that was set for creating FacesMessage, for cases where input value exceeds the maximum value set.
 String getMessageDetailMinimum()
          Return custom detail error message that was set for creating FacesMessage, for cases where, input value is less than the minimum value set.
 String getMessageDetailNotInRange()
          Return custom detail error message that was set for creating FacesMessage, for cases where, input value exceeds the maximum value and is less than the minimum value set.
 Date getMinimum()
          Return the minimum value to be enforced by this Validator, or null if it has not been set.
 javax.faces.el.ValueBinding getValueBinding(String name)
          Deprecated.  
 javax.el.ValueExpression getValueExpression(String name)
          Return the ValueExpression used to calculate the value for the specified attribute name, if any.
 int hashCode()
           
 boolean isDisabled()
          Return whether it is disabled.
 boolean isTransient()
           
 void restoreState(javax.faces.context.FacesContext context, Object state)
           
 Object saveState(javax.faces.context.FacesContext context)
           
 void setDisabled(boolean isDisabled)
          Return whether it is disabled.
 void setHintMaximum(String hintMaximum)
          Custom hint maximum message.
 void setHintMinimum(String hintMinimum)
          Custom hint minimum message.
 void setHintNotInRange(String hintNotInRange)
          Custom hint notInRange message.
 void setMaximum(Date maximum)
          Set the maximum value to be enforced by this Validator.
 void setMessageDetailMaximum(String maximumMessageDetail)
          Custom error message to be used, for creating detail part of the FacesMessage, when input value exceeds the maximum value set.
 void setMessageDetailMinimum(String minimumMessageDetail)
          Custom error message to be used, for creating detail part of the FacesMessage, when input value is less the set minimum value.
 void setMessageDetailNotInRange(String notInRangeMessageDetail)
          Custom error message to be used, for creating detail part of the FacesMessage, when input value is not with in the range, when minimum and maximum is set.
 void setMinimum(Date minimum)
          Set the minimum value to be enforced by this Validator.
 void setTransient(boolean transientValue)
           
 void setValueBinding(String name, javax.faces.el.ValueBinding binding)
          Deprecated.  
 void setValueExpression(String name, javax.el.ValueExpression expression)
          Set the ValueExpression used to calculate the value for the specified attribute if any.
 void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALIDATOR_ID

public static final String VALIDATOR_ID
See Also:
Constant Field Values

MAXIMUM_MESSAGE_ID

public static final String MAXIMUM_MESSAGE_ID

The message identifier of the FacesMessage to be created if the maximum value check fails. The message format string for this message may optionally include {0}, {1} and {3} placeholders, which will be replaced by user input, component label and configured maximum value.

See Also:
Constant Field Values

MINIMUM_MESSAGE_ID

public static final String MINIMUM_MESSAGE_ID

The message identifier of the FacesMessage to be created if the minimum value check fails. The message format string for this message may optionally include {0}, {1} and {2} placeholders, which will be replaced by user input, component label and configured minimum value.

See Also:
Constant Field Values

NOT_IN_RANGE_MESSAGE_ID

public static final String NOT_IN_RANGE_MESSAGE_ID

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 {0}, {1}, {2} and {3} placeholders, which will be replaced by user input, component label, configured minimum value and configured maximum value.

See Also:
Constant Field Values
Constructor Detail

DateTimeRangeValidator

public DateTimeRangeValidator()
Construct a Validator with no preconfigured limits.


DateTimeRangeValidator

public DateTimeRangeValidator(Date maximum)
Construct a Validator with the specified preconfigured limit.

Parameters:
maximum - Maximum value to allow

DateTimeRangeValidator

public DateTimeRangeValidator(Date maximum,
                              Date minimum)
Construct a Validator with the specified preconfigured limits.

Parameters:
maximum - Maximum value to allow
minimum - Minimum value to allow
Method Detail

getMaximum

@JSFProperty
public Date getMaximum()
Return the maximum value to be enforced by this Validator or null if it has not been set.


setMaximum

public void setMaximum(Date maximum)
Set the maximum value to be enforced by this Validator.

Parameters:
maximum - The new maximum value

getMinimum

@JSFProperty
public Date getMinimum()
Return the minimum value to be enforced by this Validator, or null if it has not been set.


setMinimum

public void setMinimum(Date minimum)
Set the minimum value to be enforced by this Validator.

Parameters:
minimum - The new minimum value

setMessageDetailMaximum

public void setMessageDetailMaximum(String maximumMessageDetail)

Custom error message to be used, for creating detail part of the FacesMessage, when input value exceeds the maximum value set.

Overrides detail message identified by message id MAXIMUM_MESSAGE_ID

Parameters:
maximumMessageDetail - Custom error message.

getMessageDetailMaximum

@JSFProperty
public String getMessageDetailMaximum()

Return custom detail error message that was set for creating FacesMessage, for cases where input value exceeds the maximum value set.

Returns:
Custom error message.
See Also:
setMessageDetailMaximum(String)

setMessageDetailMinimum

public void setMessageDetailMinimum(String minimumMessageDetail)

Custom error message to be used, for creating detail part of the FacesMessage, when input value is less the set minimum value.

Overrides detail message identified by message id MINIMUM_MESSAGE_ID

Parameters:
minimumMessageDetail - Custom error message.

getMessageDetailMinimum

@JSFProperty
public String getMessageDetailMinimum()

Return custom detail error message that was set for creating FacesMessage, for cases where, input value is less than the minimum value set.

Returns:
Custom error message.
See Also:
setMessageDetailMinimum(String)

setMessageDetailNotInRange

public void setMessageDetailNotInRange(String notInRangeMessageDetail)

Custom error message to be used, for creating detail part of the FacesMessage, when input value is not with in the range, when minimum and maximum is set.

Overrides detail message identified by message id NOT_IN_RANGE_MESSAGE_ID

Parameters:
notInRangeMessageDetail - Custom error message.

getMessageDetailNotInRange

@JSFProperty
public String getMessageDetailNotInRange()

Return custom detail error message that was set for creating FacesMessage, for cases where, input value exceeds the maximum value and is less than the minimum value set.

Returns:
Custom error message.
See Also:
setMessageDetailNotInRange(String)

setHintMaximum

public void setHintMaximum(String hintMaximum)

Custom hint maximum message.

Overrides default hint message

Parameters:
hintMaximum - Custom hint message.

getHintMaximum

@JSFProperty(tagExcluded=true)
public String getHintMaximum()

Return custom hint maximum message.

Returns:
Custom hint message.
See Also:
setHintMaximum(String)

setHintMinimum

public void setHintMinimum(String hintMinimum)

Custom hint minimum message.

Overrides default hint message

Parameters:
hintMinimum - Custom hint message.

getHintMinimum

@JSFProperty(tagExcluded=true)
public String getHintMinimum()

Return custom hint minimum message.

Returns:
Custom hint message.
See Also:
setHintMinimum(String)

setHintNotInRange

public void setHintNotInRange(String hintNotInRange)

Custom hint notInRange message.

Overrides default hint message

Parameters:
hintNotInRange - Custom hint message.

getHintNotInRange

@JSFProperty(tagExcluded=true)
public String getHintNotInRange()

Return custom hint notInRange message.

Returns:
Custom hint message.
See Also:
setHintNotInRange(String)

validate

public void validate(javax.faces.context.FacesContext context,
                     javax.faces.component.UIComponent component,
                     Object value)
              throws javax.faces.validator.ValidatorException
Specified by:
validate in interface javax.faces.validator.Validator
Throws:
IllegalArgumentException - if value is not of type Date
javax.faces.validator.ValidatorException

saveState

public Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder

restoreState

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

setValueExpression

public void setValueExpression(String name,
                               javax.el.ValueExpression expression)

Set the ValueExpression used to calculate the value for the specified attribute if any.

Parameters:
name - Name of the attribute for which to set a ValueExpression
expression - The ValueExpression to set, or null to remove any currently set ValueExpression
Throws:
NullPointerException - if name is null
IllegalArgumentException - if name is not a valid attribute of this converter

getValueExpression

public javax.el.ValueExpression getValueExpression(String name)

Return the ValueExpression used to calculate the value for the specified attribute name, if any.

Parameters:
name - Name of the attribute or property for which to retrieve a ValueExpression
Throws:
NullPointerException - if name is null
IllegalArgumentException - if name is not a valid attribute of this converter

setValueBinding

public void setValueBinding(String name,
                            javax.faces.el.ValueBinding binding)
Deprecated. 

Set the ValueBinding used to calculate the value for the specified attribute if any.

Parameters:
name - Name of the attribute for which to set a ValueBinding
binding - The ValueBinding to set, or null to remove any currently set ValueBinding
Throws:
NullPointerException - if name is null
IllegalArgumentException - if name is not a valid attribute of this validator

getValueBinding

public javax.faces.el.ValueBinding getValueBinding(String name)
Deprecated. 

Return the ValueBinding used to calculate the value for the specified attribute name, if any.

Parameters:
name - Name of the attribute or property for which to retrieve a ValueBinding
Throws:
NullPointerException - if name is null
IllegalArgumentException - if name is not a valid attribute of this validator

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isTransient

@JSFProperty(istransient=true,
             tagExcluded=true)
public boolean isTransient()
Specified by:
isTransient in interface javax.faces.component.StateHolder

setTransient

public void setTransient(boolean transientValue)
Specified by:
setTransient in interface javax.faces.component.StateHolder

setDisabled

public void setDisabled(boolean isDisabled)
Return whether it is disabled.


isDisabled

public boolean isDisabled()
Return whether it is disabled.

Returns:
true if it's disabled and false if it's enabled.


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.