DateTimePickerpublic class DateTimePicker extends UIBean
Renders a date/time picker in a dropdown container.
A stand-alone DateTimePicker widget that makes it easy to select a date/time, or increment by week, month,
and/or year.
It is possible to customize the user-visible formatting with either the
'formatLength' (long, short, medium or full) or 'displayFormat' attributes. By defaulty current
locale will be used.
Syntax supported by 'displayFormat' is (http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns):-
Format |
Description |
d |
Day of the month |
D |
Day of year |
M |
Month - Use one or two for the numerical month, three for the abbreviation, or four for the full name, or 5 for the narrow name. |
h |
Hour [1-12]. |
H |
Hour [0-23]. |
m |
Minute. Use one or two for zero padding. |
s |
Second. Use one or two for zero padding. |
The value sent to the server is
typically a locale-independent value in a hidden field as defined by the name
attribute. RFC3339 representation is the format used.
Examples
Example 1:
<s:datetimepicker name="order.date" label="Order Date" />
Example 2:
<s:datetimepicker name="delivery.date" label="Delivery Date" format="yyyy-MM-dd" />
The css could be changed by using the following :-
<s:datetimepicker name="birthday" label="Birthday" templateCss="...." />
|
Fields Summary |
---|
public static final String | TEMPLATE | private static final SimpleDateFormat | RFC3339_FORMAT | protected static final Log | LOG | protected String | iconPath | protected String | formatLength | protected String | displayFormat | protected String | toggleType | protected String | toggleDuration | protected String | type | protected String | displayWeeks | protected String | adjustWeeks | protected String | startDate | protected String | endDate | protected String | weekStartsOn | protected String | staticDisplay | protected String | dayWidth | protected String | language | protected String | templateCssPath |
Methods Summary |
---|
public void | evaluateParams()
super.evaluateParams();
if(displayWeeks != null)
addParameter("displayWeeks", findString(displayWeeks));
if(adjustWeeks != null)
addParameter("adjustWeeks", findValue(adjustWeeks, Boolean.class));
if(startDate != null)
addParameter("startDate", findString(startDate));
if(endDate != null)
addParameter("endDate", findString(endDate));
if(weekStartsOn != null)
addParameter("weekStartsOn", findString(weekStartsOn));
if(staticDisplay != null)
addParameter("staticDisplay", findValue(staticDisplay, Boolean.class));
if(dayWidth != null)
addParameter("dayWidth", findValue(dayWidth, Integer.class));
if(language != null)
addParameter("language", findString(language));
if(value != null)
addParameter("value", findString(value));
if(iconPath != null)
addParameter("iconPath", findString(iconPath));
if(formatLength != null)
addParameter("formatLength", findString(formatLength));
if(displayFormat != null)
addParameter("displayFormat", findString(displayFormat));
if(toggleType != null)
addParameter("toggleType", findString(toggleType));
if(toggleDuration != null)
addParameter("toggleDuration", findValue(toggleDuration,
Integer.class));
if(type != null)
addParameter("type", findString(type));
else
addParameter("type", "date");
if(templateCssPath != null)
addParameter("templateCssPath", findString(templateCssPath));
// format the value to RFC 3399
if(parameters.containsKey("value")) {
parameters.put("nameValue", format(parameters.get("value")));
} else {
if(name != null) {
String expr = name;
if(altSyntax()) {
expr = "%{" + expr + "}";
}
addParameter("nameValue", format(findValue(expr)));
}
}
| private java.lang.String | format(java.lang.Object obj)
if(obj == null)
return null;
if(obj instanceof Date) {
return RFC3339_FORMAT.format((Date) obj);
} else {
// try to parse a date
String dateStr = obj.toString();
if(dateStr.equalsIgnoreCase("today"))
return RFC3339_FORMAT.format(new Date());
try {
Date date = null;
if(this.displayFormat != null) {
SimpleDateFormat format = new SimpleDateFormat(
(String) getParameters().get("displayFormat"));
date = format.parse(dateStr);
return RFC3339_FORMAT.format(date);
} else {
// last resource to assume already in correct/default format
return dateStr;
}
} catch (ParseException e) {
LOG.error("Could not parse date", e);
return dateStr;
}
}
| protected java.lang.String | getDefaultTemplate()
return TEMPLATE;
| public void | setAdjustWeeks(java.lang.String adjustWeeks)
this.adjustWeeks = adjustWeeks;
| public void | setDayWidth(java.lang.String dayWidth)
this.dayWidth = dayWidth;
| public void | setDisplayFormat(java.lang.String displayFormat)
this.displayFormat = displayFormat;
| public void | setDisplayWeeks(java.lang.String displayWeeks)
this.displayWeeks = displayWeeks;
| public void | setEndDate(java.lang.String endDate)
this.endDate = endDate;
| public void | setFormatLength(java.lang.String formatLength)
this.formatLength = formatLength;
| public void | setIconPath(java.lang.String iconPath)
this.iconPath = iconPath;
| public void | setLanguage(java.lang.String language)
this.language = language;
| public void | setStartDate(java.lang.String startDate)
this.startDate = startDate;
| public void | setStaticDisplay(java.lang.String staticDisplay)
this.staticDisplay = staticDisplay;
| public void | setTemplateCssPath(java.lang.String templateCssPath)
this.templateCssPath = templateCssPath;
| public void | setToggleDuration(java.lang.String toggleDuration)
this.toggleDuration = toggleDuration;
| public void | setToggleType(java.lang.String toggleType)
this.toggleType = toggleType;
| public void | setType(java.lang.String type)
this.type = type;
| public void | setWeekStartsOn(java.lang.String weekStartsOn)
this.weekStartsOn = weekStartsOn;
|
|