fc.web.forms
Class VTime
java.lang.Object
fc.web.forms.FieldValidator
fc.web.forms.VTime
public final class VTime
- extends FieldValidator
Validates a time entered in a text box. Typical examples may
look like: 1:23 pm, 1 am, 1:00 am,
and 01:23 pm (with or without "am/pm" as part of the
entered text). By default, all of the above patterns are allowed and
the space between the time and "am/pm" is optional. This can be
changed via the useAM_PM
and allowSpaceBeforeAM_PM(boolean)
methods.
Method Summary |
void |
allowSpaceBeforeAM_PM(boolean allow)
|
void |
useAM_PM(boolean useAM_PM)
|
boolean |
validate(FormData fd,
javax.servlet.http.HttpServletRequest req)
Works with any field that returns a String via it's Field#getValue method. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
VTime
public VTime(AbstractText field,
java.lang.String errorMessage)
useAM_PM
public void useAM_PM(boolean useAM_PM)
allowSpaceBeforeAM_PM
public void allowSpaceBeforeAM_PM(boolean allow)
validate
public boolean validate(FormData fd,
javax.servlet.http.HttpServletRequest req)
- Works with any field that returns a String via it's
Field#getValue
method.
If validation succeeds, this method puts the parsed date in the specified
form data as the validated value for the target field. This saves the
hassle of reparsing the text when (typically) retrieving it later to save
the value out to the database.
- Specified by:
validate
in class FieldValidator
- Throws:
java.lang.ClassCastException
- If the field's Field#getValue
method
does not return a String