com.opensymphony.webwork.components
Class DatePicker
java.lang.Object
com.opensymphony.webwork.components.Component
com.opensymphony.webwork.components.UIBean
com.opensymphony.webwork.components.TextField
com.opensymphony.webwork.components.DatePicker
public class DatePicker
- extends TextField
Renders datepicker element.
Implementation was changed in WebWork 2.2 to use jscalendar
instead of non locale aware tigracalendar. Check locale and format settings if you used the old widget in your
applications. Be sure to include proper stylesheet as described below if you don't want the calender widget to look
transparent.
Important: Be sure to set the id attributs if not used within a <ww:form /> tag, as it takes care of
setting the id for you, being required to copy selected date to text input element.
Following a reference for the format parameter (copied from jscalendar documentation):
|
%a | abbreviated weekday name |
%A | full weekday name |
%b | abbreviated month name |
%B | full month name |
%C | century number |
%d | the day of the month ( 00 .. 31 ) |
%e | the day of the month ( 0 .. 31 ) |
%H | hour ( 00 .. 23 ) |
%I | hour ( 01 .. 12 ) |
%j | day of the year ( 000 .. 366 ) |
%k | hour ( 0 .. 23 ) |
%l | hour ( 1 .. 12 ) |
%m | month ( 01 .. 12 ) |
%M | minute ( 00 .. 59 ) |
%n | a newline character |
%p | ``PM'' or ``AM'' |
%P | ``pm'' or ``am'' |
%S | second ( 00 .. 59 ) |
%s | number of seconds since Epoch (since Jan 01 1970 00:00:00 UTC) |
%t | a tab character |
%U, %W, %V | the week number |
%u | the day of the week ( 1 .. 7, 1 = MON ) |
%w | the day of the week ( 0 .. 6, 0 = SUN ) |
%y | year without the century ( 00 .. 99 ) |
%Y | year including the century ( ex. 1979 ) |
%% | a literal % character
|
Examples
Date in application's locale format:
<ww:datepicker name="order.date" id="order.date" />
Date in german locale, with german texts:
<ww:datepicker name="delivery.date" id="delivery.date" template="datepicker_js.ftl" language="de" />
Date in german locale, with german texts and custom date format, including time:
<ww:datepicker name="invoice.date" id="invoice.date" template="datepicker_js.ftl" language="de" format="%d. %b &Y %H:%M" showstime="true" />
If you use this jscalendar based datepicker widget, you might want to use one of the standard stylesheets provided
with jscalendar (all distribution stylesheets are included in webwork jar). The easiest way to do so is to place the
<ww:head/> tag in the head of your html page, as it takes care of including calendar css.
Otherwise, to manually activate the calendar-blue style, include the following in your stylesheet definition:
<link href="<ww:url value="/webwork/jscalendar/calendar-blue.css" />" rel="stylesheet" type="text/css" media="all"/>
- Since:
- 2.2
- Version:
- $Revision: 2541 $
- Author:
- Patrick Lightbody, Rene Gielen
Fields inherited from class com.opensymphony.webwork.components.UIBean |
accesskey, cssClass, cssStyle, disabled, label, labelPosition, name, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, request, required, requiredposition, response, tabindex, template, templateDir, templateSuffix, theme, title, tooltip, tooltipConfig, value |
Methods inherited from class com.opensymphony.webwork.components.UIBean |
addFormParameter, buildTemplateName, enableAncestorFormCustomOnsubmit, end, escape, evaluateNameValue, getTemplate, getTemplateDir, getTheme, getTooltipConfig, getValueClassType, mergeTemplate, populateComponentHtmlId, setAccesskey, setCssClass, setCssStyle, setDisabled, setLabel, setLabelposition, setLabelPosition, setName, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setRequired, setRequiredposition, setTabindex, setTemplate, setTemplateDir, setTheme, setTitle, setTooltip, setTooltipConfig, setValue |
Methods inherited from class com.opensymphony.webwork.components.Component |
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setId, start, toString, usesBody |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TEMPLATE
public static final String TEMPLATE
- See Also:
- Constant Field Values
language
protected String language
format
protected String format
showstime
protected String showstime
singleclick
protected String singleclick
DatePicker
public DatePicker(OgnlValueStack stack,
HttpServletRequest request,
HttpServletResponse response)
getDefaultTemplate
protected String getDefaultTemplate()
- Description copied from class:
UIBean
- A contract that requires each concrete UI Tag to specify which template should be used as a default. For
example, the CheckboxTab might return "checkbox.vm" while the RadioTag might return "radio.vm". This value
not begin with a '/' unless you intend to make the path absolute rather than relative to the
current theme.
- Overrides:
getDefaultTemplate
in class TextField
- Returns:
- The name of the template to be used as the default.
evaluateParams
public void evaluateParams()
- Overrides:
evaluateParams
in class UIBean
setLanguage
public void setLanguage(String language)
- The language to use for the widget texts and localization presets.
setFormat
public void setFormat(String format)
- The format to use for date field.
setShowstime
public void setShowstime(String showstime)
- Whether time selector is to be shown. Valid values are "true", "false", "24" and "12".
setSingleclick
public void setSingleclick(String singleclick)
- Whether to use selected value after single or double click.