Class DateField

  extended by org.apache.tapestry5.corelib.base.AbstractField
      extended by org.apache.tapestry5.corelib.components.DateField
All Implemented Interfaces:
ClientElement, Field

public class DateField
extends AbstractField

A component used to collect a provided date from the user using a client-side JavaScript calendar. Non-JavaScript clients can simply type into a text field.

One wierd aspect here is that, because client-side JavaScript formatting and parsing is so limited, we (currently) use Ajax to send the user's input to the server for parsing (before raising the popup) and formatting (after closing the popup). Weird and inefficient, but easier than writing client-side JavaScript for that purpose.

Tapestry's DateField component is a wrapper around WebFX DatePicker.

See Also:
Form, TextField
Component Parameters
NameDescriptionTypeFlagsDefaultDefault PrefixSince
clientIdThe id used to generate a page-unique client-side identifier for the component. If a component renders multiple times, a suffix will be appended to the to id to ensure uniqueness. The uniqued value may be accessed via the clientId property.Stringprop:componentResources.idliteral
disabledIf true, then the field will render out with a disabled attribute (to turn off client-side behavior). When the form is submitted, the bound value is evaluated again and, if true, the field's value is ignored (not even validated) and the component's events are not fired.booleanfalseprop
formatThe format used to format and parse dates. This is typically specified as a string which is coerced to a DateFormat. You should be aware that using a date format with a two digit year is problematic: Java (not Tapestry) may get confused about the, Not Nullliteral
hideTextFieldIf true, then the text field will be hidden, and only the icon for the date picker will be visible. The default is false.booleanprop
labelThe user presentable label for the field. If not provided, a reasonable label is generated from the component's id, first by looking for a message key named "id-label" (substituting the component's actual id), then by converting the actual id to a presentable string (for example, "userId" to "User Id").Stringliteral
messagesUsed to override the component's message
validateThe object that will perform input validation (which occurs after translation). The translate binding prefix is generally used to provide this object in a declarative
valueThe value parameter of a DateField must be a



The DateField component is very easy to use, all the JavaScript is generated for you. Then end result looks like:

Note: these screenshots are out of date, and reflect an earlier version of Tapestry and a different third-party JavaScript calendar than is currently available.

Clicking the icon raises the popup calendar:


<html xmlns:t="">
            <div class="t-beaneditor">
                <div class="t-beaneditrow">
                    <t:label for="date"/>
                    <t:datefield t:id="date"/>
                <div class="t-beaneditrow">
                    <input type="submit" value="Update"/>

The use of the extra

elements is to trigger the CSS styles that are usually used as part of a BeanEditForm. Just the <t:datefield> element is all that's really necessary.

Constructor Summary
Method Summary
 boolean isRequired()
          Returns false; most components do not support declarative validation.
protected  void processSubmission(String controlName)
          Method implemented by subclasses to actually do the work of processing the submission of the form.
Methods inherited from class org.apache.tapestry5.corelib.base.AbstractField
decorateInsideField, getClientId, getControlName, getLabel, isDisabled, putPropertyNameIntoBeanValidationContext, removePropertyNameFromBeanValidationContext, setDecorator, setFormSupport
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public DateField()
Method Detail


protected void processSubmission(String controlName)
Description copied from class: AbstractField
Method implemented by subclasses to actually do the work of processing the submission of the form. The element's controlName property will already have been set. This method is only invoked if the field is not disabled.

Specified by:
processSubmission in class AbstractField
controlName - the control name of the rendered element (used to find the correct parameter in the request)


public boolean isRequired()
Description copied from class: AbstractField
Returns false; most components do not support declarative validation.

Specified by:
isRequired in interface Field
isRequired in class AbstractField
true if a non-blank value is required for the field

Copyright © 2003-2012 The Apache Software Foundation.