The dateTimeEntry component allows you to enter a date and/or a time. You can enter the date/time as text or pick the date/time from an inline or popup calendar. When entering as text, the format is as specified in the pattern attribute.
|See the ICEfaces Showcase Live Demo of this component, complete with source code.|
This section covers attributes involved in the typical use-cases for this component. For reference, the complete taglib documentation for this component is available here.
value is value of the component as a java.util.Date object. Default is current date and time.
renderAsPopup determines whether the calendar is displayed inline or as a popup. Default is false, i.e. inline.
The pattern attribute is used to specify the date/time format of the text input field. It also affects whether the time entry sliders appear in the calendar. The pattern characters are as detailed in the java.text.SimpleDateFormat javadoc. When an hour field is present in the pattern, the time entry sliders will appear. Some uncommon pattern characters (e.g. G, w, K, k) may not be translatable to pattern characters for the client side date/time object. The following pattern characters are supported: y, M, d, E, a, H, h, m, s, z. But even with these supported pattern characters the formatting may not be exactly the same on the server side and client side. E.g.:
- "EEEE" is long day name in Java, but translated to "DE", where "D" is short day name in datepicker and "E" is literal "E". So "Wednesday" becomes "WedE". To work around this, use "EEEEEE" instead, which is translated to long day name in datepicker ("DD").
- "m" can only mean minute in Java, but can mean month in datepicker or minute in timepicker. To avoid confusion, always use "M" in the date portion and "m" in the time portion.
timeZone is used to set the date's time zone. It can be a string or java.util.TimeZone object.
Month/year navigation is by left and right arrow images, one month at a time. To also navigate by month/year drop down lists, set navigator to true.
To enter time only, set timeOnly to true.
Multiple months can be displayed by specifying the no. of months in pages.
|| Listener method that will be notified when a new value has been set for this input component.
Client Behavior Events
|| Fired when a date is selected from the calendar (default event).
|| Fired when date text is changed and input field loses focus.
The client side component object is exposed through the global variable name specified in the widgetVar attribute.
var widget = ice.ace.instance('frm:componentId);
|The ice.ace.instance function requires the full client id of the component to be specified, such as "j_idt77:componentId" instead of just "componentId". To reduce the complexity of working with complete IDs with this function it may be preferable in some cases to use prependId="false" in the enclosing form (e.g. <h:form prependId="false">).|
Keyboard and ARIA Support
These keyboard shortcuts work only in a popup calendar without the time component. Some of them may conflict with browser keyboard shortcuts.
| page up/down
|| previous/next month
| ctrl+page up/down
|| previous/next year
|| current month or open when closed
|| previous/next day
|| previous/next week
|| select the focused day
|| close and erase the date
|| close the calendar without selection
The following ARIA roles are supported: grid, presentation, heading, columnheader, gridcell, textbox.
This component supports built-in labels. The text specified in the label attribute will be rendered next to the main input field of this component. The position specified by labelPosition will determine where this label is going to be rendered; the possible values are left, right, top, bottom, none and inField (to render the label in the field itself).
The requiredIndicator attribute specifies the text to be displayed next to the main input field when this component is marked as required. When, this component is not marked as required, then the text specified in the optionalIndicator is going to be rendered. The indicatorPosition attribute determines where this indicator text is going to the rendered; the possible values are left, right, top, bottom, labelLeft, labelRight, and none.
Then this component is marked as required, the main input field receives the CSS class ui-state-required, otherwise, it receives the CSS class ui-state-optional. When this component is marked as invalid by the app, it will be rendered with the CSS class ui-state-error. These CSS classes can be used to add custom styling to this component, in order indicate its current state in a more visual way.
The following markup represents the basic HTML structure of the component and the CSS classes it uses.
<span class="[user defined classes]" style="[user defined styles]">
<div class="ui-datepicker-inline ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">
<a class="ui-datepicker-prev ui-corner-all">
<span class="ui-icon ui-icon-circle-triangle-w">Prev</span>
<a class="ui-datepicker-next ui-corner-all">
<span class="ui-icon ui-icon-circle-triangle-e">Next</span>
<th class="ui-datepicker-week-end" role="columnheader">
The lenientParsing attribute is turned on by default and it enables the lenient mode of java.text.DateFormat when converting inputs to Date objects. It is also turned on by default in java.text.DateFormat. When this is enabled, the user can enter out-of-range values and the input will still be parsed successfully (i.e. there won't be a ParseException). However, the results might be quite different from what's expected. The following example is taken from the java.util.Calendar javadoc.
With lenient interpretation, a date such as "February 942, 1996" will be treated as being equivalent to the 941st day after February 1, 1996. With strict (non-lenient) interpretation, such dates will cause an exception to be thrown.
Tutorial on setting locale