org.apache.myfaces.html5.validator
Class DateTimeRangeValidator

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

@JSFValidator(name="fx:validateDateTimeRange",
              bodyContent="empty",
              tagClass="org.apache.myfaces.html5.tag.input.ValidateDateTimeRangeTag",
              id="org.apache.myfaces.html5.DateTimeRange")
public class DateTimeRangeValidator
extends Object
implements javax.faces.validator.Validator, javax.faces.component.PartialStateHolder

Validate that the date entered is within a given range. Rendered min/max attributes of hx:inputDateTime is driven by this validator too.

Author:
Ali Ok

Field Summary
 
Fields inherited from interface javax.faces.validator.Validator
NOT_IN_RANGE_MESSAGE_ID
 
Constructor Summary
DateTimeRangeValidator()
           
 
Method Summary
 void clearInitialState()
           
 String getExceedMaximumMessage()
          Message to show if the minimum is not set and submitted value exceeds specified maximum value.
 String getLessThanMinimumMessage()
          Message to show if the maximum is not set and submitted value is before than specified minimum value.
 Object getMaximum()
          Maximum date that can be selected on client-side and is used on validation at server-side.
 Object getMinimum()
          Minimum date that can be selected on client-side and is used on validation at server-side.
 String getNotInRangeMessage()
          Message to show if the minimum and minimum is set and submitted value is not in that range.
 Date getResolvedMaximum(String type)
          Resolves the maximum date from the maximum property which accepts both java.util.Date and String.
 Date getResolvedMinimum(String type)
          Resolves the minimum date from the minimum property which accepts both java.util.Date and String.
 boolean initialStateMarked()
           
 boolean isTransient()
           
 void markInitialState()
           
 void restoreState(javax.faces.context.FacesContext context, Object state)
           
 Object saveState(javax.faces.context.FacesContext context)
           
 void setExceedMaximumMessage(String exceedMaximumMessage)
           
 void setLessThanMinimumMessage(String lessThanMinimumMessage)
           
 void setMaximum(Object maximum)
           
 void setMinimum(Object minimum)
           
 void setNotInRangeMessage(String notInRangeMessage)
           
 void setTransient(boolean transientValue)
           
 void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent uiComponent, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTimeRangeValidator

public DateTimeRangeValidator()
Method Detail

validate

public void validate(javax.faces.context.FacesContext context,
                     javax.faces.component.UIComponent uiComponent,
                     Object value)
              throws javax.faces.validator.ValidatorException
Specified by:
validate in interface javax.faces.validator.Validator
Throws:
javax.faces.validator.ValidatorException

getResolvedMinimum

public Date getResolvedMinimum(String type)
                        throws ParseException
Resolves the minimum date from the minimum property which accepts both java.util.Date and String.

Throws:
ParseException - if the value of minimum property is String and cannot be parsed for the given type.

getResolvedMaximum

public Date getResolvedMaximum(String type)
                        throws ParseException
Resolves the maximum date from the maximum property which accepts both java.util.Date and String.

Throws:
ParseException - if the value of maximum property is String and cannot be parsed for the given type.

getMinimum

@JSFProperty(deferredValueType="java.lang.Object")
public Object getMinimum()
Minimum date that can be selected on client-side and is used on validation at server-side. Value must be either String, or java.util.Date. If String is given, the value must be in the format of parent hx:inputDateTime's type.


setMinimum

public void setMinimum(Object minimum)

getMaximum

@JSFProperty(deferredValueType="java.lang.Object")
public Object getMaximum()
Maximum date that can be selected on client-side and is used on validation at server-side. Value must be either String, or java.util.Date. If String is given, the value must be in the format of parent hx:inputDateTime's type.


setMaximum

public void setMaximum(Object maximum)

getExceedMaximumMessage

@JSFProperty(deferredValueType="java.lang.String")
public String getExceedMaximumMessage()
Message to show if the minimum is not set and submitted value exceeds specified maximum value.


setExceedMaximumMessage

public void setExceedMaximumMessage(String exceedMaximumMessage)

getLessThanMinimumMessage

@JSFProperty(deferredValueType="java.lang.String")
public String getLessThanMinimumMessage()
Message to show if the maximum is not set and submitted value is before than specified minimum value.


setLessThanMinimumMessage

public void setLessThanMinimumMessage(String lessThanMinimumMessage)

getNotInRangeMessage

@JSFProperty(deferredValueType="java.lang.String")
public String getNotInRangeMessage()
Message to show if the minimum and minimum is set and submitted value is not in that range.


setNotInRangeMessage

public void setNotInRangeMessage(String notInRangeMessage)

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

isTransient

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

clearInitialState

public void clearInitialState()
Specified by:
clearInitialState in interface javax.faces.component.PartialStateHolder

initialStateMarked

public boolean initialStateMarked()
Specified by:
initialStateMarked in interface javax.faces.component.PartialStateHolder

markInitialState

public void markInitialState()
Specified by:
markInitialState in interface javax.faces.component.PartialStateHolder


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.