org.apache.tapestry.valid
Class DateValidator

java.lang.Object
  extended byorg.apache.tapestry.valid.BaseValidator
      extended byorg.apache.tapestry.valid.DateValidator
All Implemented Interfaces:
IValidator

public class DateValidator
extends BaseValidator

Provides input validation for strings treated as dates. In addition, allows a minimum and maximum date to be set.

Since:
1.0.8
Author:
Howard Lewis Ship

Field Summary
 
Fields inherited from class org.apache.tapestry.valid.BaseValidator
FIELD_SYMBOL, FORM_SYMBOL, FUNCTION_SYMBOL, VALIDATOR_SYMBOL
 
Constructor Summary
DateValidator()
           
DateValidator(java.lang.String initializer)
          Initializes the DateValidator with properties defined by the initializer.
 
Method Summary
protected  java.lang.String buildDateTooEarlyMessage(IFormComponent field, java.lang.String earliestDate)
           
protected  java.lang.String buildDateTooLateMessage(IFormComponent field, java.lang.String latestDate)
           
protected  java.lang.String buildInvalidDateFormatMessage(IFormComponent field)
           
 java.lang.String getDateTooEarlyMessage()
           
 java.lang.String getDateTooLateMessage()
           
 java.lang.String getDisplayFormat()
           
 java.lang.String getEffectiveDisplayFormat()
           
 java.text.DateFormat getEffectiveFormat()
           
 java.text.DateFormat getFormat()
           
 java.lang.String getInvalidDateFormatMessage()
           
 java.util.Date getMaximum()
           
 java.util.Date getMinimum()
           
 java.lang.String getScriptPath()
           
 void renderValidatorContribution(IFormComponent field, IMarkupWriter writer, IRequestCycle cycle)
          This implementation does nothing.
 void setDateTooEarlyMessage(java.lang.String string)
          Overrides the bundle key date-too-early.
 void setDateTooLateMessage(java.lang.String string)
          Overrides the bundle key date-too-late.
 void setDisplayFormat(java.lang.String value)
           
 void setFormat(java.text.DateFormat value)
           
 void setInvalidDateFormatMessage(java.lang.String string)
          Overrides the bundle key invalid-date-format.
 void setMaximum(java.util.Date maximum)
           
 void setMinimum(java.util.Date minimum)
           
 void setScriptPath(java.lang.String scriptPath)
          Allows a developer to use the existing validation logic with a different client-side script.
 java.lang.Object toObject(IFormComponent field, java.lang.String value)
          Converts input, submitted by the client, into an object value.
 java.lang.String toString(IFormComponent file, java.lang.Object value)
          Invoked during rendering to convert an object value (which may be null) to a String.
 
Methods inherited from class org.apache.tapestry.valid.BaseValidator
buildRequiredMessage, checkRequired, formatString, formatString, formatString, getPattern, getRequiredMessage, isClientScriptingEnabled, isRequired, processValidatorScript, setClientScriptingEnabled, setRequired, setRequiredMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateValidator

public DateValidator()

DateValidator

public DateValidator(java.lang.String initializer)
Initializes the DateValidator with properties defined by the initializer.

Since:
4.0
Method Detail

setFormat

public void setFormat(java.text.DateFormat value)

getFormat

public java.text.DateFormat getFormat()

getEffectiveFormat

public java.text.DateFormat getEffectiveFormat()
Returns:
the DateFormatthe validator will use, returning the default if no other date format is specified via setFormat(DateFormat)
Since:
3.0

getDisplayFormat

public java.lang.String getDisplayFormat()

setDisplayFormat

public void setDisplayFormat(java.lang.String value)

getEffectiveDisplayFormat

public java.lang.String getEffectiveDisplayFormat()
Returns:
the display format message the validator will use, returning the default if no other display format message is specified. The default is the SimpleDateFormat.toPattern()for SimpleDateFormats, or "MM/DD/YYYY" for unknown DateFormatsubclasses.
Since:
3.0

toString

public java.lang.String toString(IFormComponent file,
                                 java.lang.Object value)
Description copied from interface: IValidator
Invoked during rendering to convert an object value (which may be null) to a String. It is acceptible to return null. The string will be the VALUE attribute of the HTML text field.


toObject

public java.lang.Object toObject(IFormComponent field,
                                 java.lang.String value)
                          throws ValidatorException
Description copied from interface: IValidator
Converts input, submitted by the client, into an object value. May return null if the input is null (and the required flag is false).

The input string will already have been trimmed. It may be null.

Throws:
ValidatorException - if the string cannot be converted into an object, or the object is not valid (due to other constraints).

getMaximum

public java.util.Date getMaximum()

setMaximum

public void setMaximum(java.util.Date maximum)

getMinimum

public java.util.Date getMinimum()

setMinimum

public void setMinimum(java.util.Date minimum)

renderValidatorContribution

public void renderValidatorContribution(IFormComponent field,
                                        IMarkupWriter writer,
                                        IRequestCycle cycle)
Description copied from class: BaseValidator
This implementation does nothing. Subclasses may supply their own implementation.

Specified by:
renderValidatorContribution in interface IValidator
Overrides:
renderValidatorContribution in class BaseValidator
Since:
2.2

getScriptPath

public java.lang.String getScriptPath()
Since:
2.2

setScriptPath

public void setScriptPath(java.lang.String scriptPath)
Allows a developer to use the existing validation logic with a different client-side script. This is often sufficient to allow application-specific error presentation (perhaps by using DHTML to update the content of a <span> tag, or to use a more sophisticated pop-up window than window.alert()).

Since:
2.2

getDateTooEarlyMessage

public java.lang.String getDateTooEarlyMessage()
Since:
3.0

getDateTooLateMessage

public java.lang.String getDateTooLateMessage()
Since:
3.0

getInvalidDateFormatMessage

public java.lang.String getInvalidDateFormatMessage()
Since:
3.0

buildInvalidDateFormatMessage

protected java.lang.String buildInvalidDateFormatMessage(IFormComponent field)
Since:
3.0

buildDateTooEarlyMessage

protected java.lang.String buildDateTooEarlyMessage(IFormComponent field,
                                                    java.lang.String earliestDate)
Since:
3.0 *

buildDateTooLateMessage

protected java.lang.String buildDateTooLateMessage(IFormComponent field,
                                                   java.lang.String latestDate)
Since:
3.0

setDateTooEarlyMessage

public void setDateTooEarlyMessage(java.lang.String string)
Overrides the bundle key date-too-early. Parameter {0} is the display name of the field. Parameter {1} is the earliest allowed date.

Since:
3.0

setDateTooLateMessage

public void setDateTooLateMessage(java.lang.String string)
Overrides the bundle key date-too-late. Parameter {0} is the display name of the field. Parameter {1} is the latest allowed date.

Since:
3.0

setInvalidDateFormatMessage

public void setInvalidDateFormatMessage(java.lang.String string)
Overrides the bundle key invalid-date-format. Parameter {0} is the display name of the field. Parameter {1} is the allowed format.

Since:
3.0