|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.control.AbstractControl org.apache.click.control.Field org.apache.click.control.TextField org.apache.click.extras.control.DateField
public class DateField
Provides a Date Field control: <input type='text'><img>.
Date Field |
public MyPage extends Page { public void onInit() { Form form = new Form("form"); // Create new DateField with default date format: 'dd MMM yyyy' DateField dateField = new DateField("date"); // You can change the format to: 'yyyy-MM-dd' dateField.setFormatPattern("yyyy-MM-dd"); // Finally add dateField to form form.add(dateField); addControl(form); } }
setShowCalendar(boolean)
to false. No JavaScript and CSS will be
included when this option is false.
The DateField control makes use of the following resources
(which Click automatically deploys to the application directories,
/click/calendar and /click/prototype):
<html> <head> $headElements </head> <body> $form $jsElements </body> </html>
date-format-pattern=dd-MM-yyyy
Field Summary | |
---|---|
protected String |
calendarPattern
The JavaScript Calendar pattern. |
protected Date |
date
The DateField's date value. |
protected SimpleDateFormat |
dateFormat
The date format. |
protected String |
formatPattern
The date format pattern value. |
protected int |
maximumYear
The maximum year of the calendar, default value is 2050. |
protected int |
minimumYear
The minimum year of the calendar, default value is 1930. |
protected boolean |
showCalendar
Flag indicating if the Calendar popup is displayed or not, default value is true. |
protected boolean |
showTime
The Calendar popup show time display bar flag. |
protected String |
style
The Calendar CSS style, default value: default. |
Fields inherited from class org.apache.click.control.TextField |
---|
maxLength, minLength, size, VALIDATE_TEXTFIELD_FUNCTION |
Fields inherited from class org.apache.click.control.Field |
---|
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value |
Fields inherited from class org.apache.click.control.AbstractControl |
---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface org.apache.click.Control |
---|
CONTROL_MESSAGES |
Constructor Summary | |
---|---|
DateField()
Create a Date Field with no name defined. |
|
DateField(String name)
Construct the Date Field with the given name. |
|
DateField(String name,
boolean required)
Construct the Date Field with the given name and required status. |
|
DateField(String name,
String label)
Construct the Date Field with the given name and label. |
|
DateField(String name,
String label,
boolean required)
Construct the Date Field with the given name, label and required status. |
|
DateField(String name,
String label,
int size)
Construct the Date Field with the given name, label and size. |
|
DateField(String name,
String label,
int size,
boolean required)
Construct the Date Field with the given name, label, size and required status. |
Method Summary | |
---|---|
protected void |
addCalendarOptions(List<Element> headElements)
Add the calendar options as a script to the list of head elements. |
protected void |
addCalenderTranslations(List<Element> headElements)
Return the names of months and weekdays as a script. |
String |
getCalendarPattern()
Return the JavaScript Calendar pattern. |
Date |
getDate()
Return the field Date value, or null if value was empty or a parsing error occurred. |
SimpleDateFormat |
getDateFormat()
Return the SimpleDateFormat for the formatPattern property. |
protected int |
getFirstDayOfWeek()
Return the first day of the week. |
String |
getFormatPattern()
Return the date format pattern. |
List<Element> |
getHeadElements()
Return the DateField HTML head imports statements for the following resources: click/calendar/{style}.css - where {style} is a specific Calendar style e.g. |
String |
getHelp()
Return the field help text. |
protected Locale |
getLocale()
Returns the Locale that should be used in this control. |
int |
getMaximumYear()
Return the maximum year of the Calendar, default value is 2050. |
int |
getMinimumYear()
Return the minimum year of the Calendar, default value is 1930. |
String |
getStyle()
Return the Calendar CSS style. |
Timestamp |
getTimestamp()
Return the Timestamp value, or null if value was empty or a parsing error occurred. |
Object |
getValueObject()
Return the field Date value, or null if value was empty or a parsing error occurred. |
boolean |
isShowCalendar()
Return true if the Calendar popup will be displayed, false otherwise. |
boolean |
isShowTime()
Return true if the Calendar popup will show the time display bar. |
protected void |
loadFormatPattern()
Load the default date format pattern. |
protected String |
parseDateFormatPattern(String pattern)
Return the JavaScript Calendar pattern for the given Java DateFormat pattern. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the DateField. |
protected void |
renderCalendarButton(HtmlStringBuffer buffer)
Render the calendar button HTML representation to the buffer. |
void |
setDate(Date date)
Set the field Date value. |
void |
setFormatPattern(String pattern)
Set the SimpleDateFormat pattern. |
void |
setMaximumYear(int maximumYear)
Set the maximum year of the Calendar. |
void |
setMinimumYear(int minimumYear)
Set the minimum year of the Calendar. |
void |
setName(String name)
|
void |
setShowCalendar(boolean showCalendar)
Set whether the Calendar popup is displayed or not. |
void |
setShowTime(boolean showTime)
Set the Calendar popup show the time display bar flag. |
void |
setStyle(String style)
Set the Calendar CSS style. |
void |
setValue(String value)
Set the DateField value. |
void |
setValueObject(Object object)
Set the date value of the field using the given object. |
void |
validate()
Validate the DateField request submission. |
Methods inherited from class org.apache.click.control.TextField |
---|
getControlSizeEst, getMaxLength, getMinLength, getSize, getTag, getType, getValidationJavaScript, setMaxLength, setMinLength, setSize |
Methods inherited from class org.apache.click.control.Field |
---|
bindRequestValue, getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getState, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, onProcess, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setState, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setWidth |
Methods inherited from class org.apache.click.control.AbstractControl |
---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onDestroy, onInit, onRender, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setStyle, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Date date
protected SimpleDateFormat dateFormat
protected String formatPattern
protected String calendarPattern
protected boolean showTime
protected boolean showCalendar
protected int minimumYear
protected int maximumYear
protected String style
Constructor Detail |
---|
public DateField(String name)
name
- the name of the fieldpublic DateField(String name, String label)
name
- the name of the fieldlabel
- the label of the fieldpublic DateField(String name, boolean required)
name
- the name of the fieldrequired
- the field required statuspublic DateField(String name, String label, boolean required)
name
- the name of the fieldlabel
- the label of the fieldrequired
- the field required statuspublic DateField(String name, String label, int size)
name
- the name of the fieldlabel
- the label of the fieldsize
- the size of the fieldpublic DateField(String name, String label, int size, boolean required)
name
- the name of the fieldlabel
- the label of the fieldsize
- the size of the fieldrequired
- the field required statuspublic DateField()
Method Detail |
---|
public Date getDate()
public void setDate(Date date)
date
- the Date value to setpublic SimpleDateFormat getDateFormat()
formatPattern
property.
public String getFormatPattern()
loadFormatPattern()
.
public void setFormatPattern(String pattern)
Letter | Date or Time Component | Presentation | Examples |
---|---|---|---|
G
| Era designator | Text | AD
|
y
| Year | Year | 1996 ; 96
|
M
| Month in year | Month | July ; Jul ; 07
|
w
| Week in year | Number | 27
|
W
| Week in month | Number | 2
|
D
| Day in year | Number | 189
|
d
| Day in month | Number | 10
|
F
| Day of week in month | Number | 2
|
E
| Day in week | Text | Tuesday ; Tue
|
a
| Am/pm marker | Text | PM
|
H
| Hour in day (0-23) | Number | 0
|
k
| Hour in day (1-24) | Number | 24
|
K
| Hour in am/pm (0-11) | Number | 0
|
h
| Hour in am/pm (1-12) | Number | 12
|
m
| Minute in hour | Number | 30
|
s
| Second in minute | Number | 55
|
S
| Millisecond | Number | 978
|
z
| Time zone | General time zone | Pacific Standard Time ; PST ; GMT-08:00
|
Z
| Time zone | RFC 822 time zone | -0800
|
pattern
- the SimpleDateFormat patternpublic void setName(String name)
setName
in interface Control
setName
in class AbstractControl
name
- of the control
IllegalArgumentException
- if the name is nullAbstractControl.setName(String)
public Timestamp getTimestamp()
public void setValue(String value)
setValue
in class Field
value
- the DateField valuepublic Object getValueObject()
getValueObject
in class Field
public void setValueObject(Object object)
setValueObject
in class Field
object
- the object value to setpublic String getCalendarPattern()
format pattern
.
If the date format pattern is not defined it will be loaded through the
method loadFormatPattern()
.
public List<Element> getHeadElements()
addCalendarOptions(java.util.List)
to
include the Calendar Options script.
getHeadElements
in interface Control
getHeadElements
in class AbstractControl
Control.getHeadElements()
public boolean isShowTime()
public void setShowTime(boolean showTime)
showTime
- the flag to show the Calendar time display barpublic boolean isShowCalendar()
public void setShowCalendar(boolean showCalendar)
showCalendar
- flag indicating whether the Calendar popup is
displayed or notpublic int getMinimumYear()
public void setMinimumYear(int minimumYear)
minimumYear
- the minimum year of the Calendarpublic int getMaximumYear()
public void setMaximumYear(int maximumYear)
maximumYear
- the maximum year of the Calendarpublic String getStyle()
public void setStyle(String style)
style
- the Calendar CSS stylepublic String getHelp()
getHelp
in class Field
Field.getHelp()
public void validate()
- /click-control.properties
- field-required-error
- /org/apache/click/extras/control/DateField.properties
- date-format-error
validate
in class TextField
public void render(HtmlStringBuffer buffer)
render
in interface Control
render
in class TextField
buffer
- the specified buffer to render the control's output toAbstractControl.toString()
protected void renderCalendarButton(HtmlStringBuffer buffer)
buffer
- the buffer to render the calendar button HTML
representation toprotected void addCalendarOptions(List<Element> headElements)
Click.addLoadEvent(function() { Event.observe('my-calendar-button', 'click', function(){ calendar = new CalendarDateSelect($('my-calendar'), { minute_interval: 1, popup_by: 'my-calendar-button', embedded: false, time: 'mixed', formatValue: 'dd MMM yyyy', year_range: [1930,2050]}); }); });You can override this method to set your own options using a
JsScript
.
headElements
- the list of head elements to include for this controlprotected void addCalenderTranslations(List<Element> headElements)
protected int getFirstDayOfWeek()
protected Locale getLocale()
protected void loadFormatPattern()
protected String parseDateFormatPattern(String pattern)
pattern
- the Java DateFormat pattern
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |