PAJES 3.0.21

org.pajes.html.validation
Class IsDateTime

java.lang.Object
  extended by org.pajes.html.validation.ValidationFunction
      extended by org.pajes.html.validation.IsDateTime
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class IsDateTime
extends ValidationFunction

Creates a JavaScript validation function to validate that the value entered by the user is a date/time in the format specified by a provided DateFormat object.

See Also:
Serialized Form

Constructor Summary
IsDateTime()
          Creates a JavaScript validation function.
IsDateTime(InputField element, java.lang.String displayName, java.text.SimpleDateFormat format, boolean mandatory)
          Creates a JavaScript validation function.
 
Method Summary
static java.lang.String getPattern(java.text.SimpleDateFormat format)
          Creates an appropriate format pattern, using the specified SimpleDateFormat as a template.
 int length()
          Returns the length of the format mask.
 void setFormatMask(java.text.SimpleDateFormat format)
          Sets the formatMask.
 void setFormatMask(java.lang.String formatMask)
          Sets the formatMask.
 java.lang.String toJavaScript(Browser browser)
          Converts the validation function into a string to be returned to the browser.
 
Methods inherited from class org.pajes.html.validation.ValidationFunction
clone, getDisplayName, getInputField, isMandatory, setDisplayName, setInputField, setMandatory, setMandatory, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IsDateTime

public IsDateTime()
Creates a JavaScript validation function.


IsDateTime

public IsDateTime(InputField element,
                  java.lang.String displayName,
                  java.text.SimpleDateFormat format,
                  boolean mandatory)
Creates a JavaScript validation function.

Parameters:
element - the input field to be validated.
displayName - the name of the field that will appear in any error messages.
format - the format mask with which the user input must comply.
mandatory - true if a value is required, or false if it may be left blank.
Method Detail

getPattern

public static java.lang.String getPattern(java.text.SimpleDateFormat format)
Creates an appropriate format pattern, using the specified SimpleDateFormat as a template. This method adjusts the pattern by changing single format symbols into double format symbols (e.g. "d/MM/yy" becomes "dd/MM/yy").

Parameters:
format - the format mask with which the user input must comply.
Returns:
a pattern, suitable as a parameter to the SimpleDateFormat.applyPattern method.
Throws:
java.lang.IllegalArgumentException - if the JavaScript validation will not be able to handle the specified format.

length

public int length()
Returns the length of the format mask.

Returns:
the format mask length.

setFormatMask

public void setFormatMask(java.text.SimpleDateFormat format)
Sets the formatMask.

Parameters:
format - the format mask with which the user input must comply.

setFormatMask

public void setFormatMask(java.lang.String formatMask)
Sets the formatMask.

Parameters:
formatMask - the format mask with which the user input must comply.

toJavaScript

public java.lang.String toJavaScript(Browser browser)
Converts the validation function into a string to be returned to the browser.

Specified by:
toJavaScript in class ValidationFunction
Parameters:
browser - the browser object.
Returns:
the string consisting of the JavaScript function that will be sent to the browser to validate the input field.

PAJES 3.0.21

Copyright © 1998-2007 Viridian Pty Limited. All Rights Reserved.