Interface IDatebox
- All Superinterfaces:
IAnyGroup<IDatebox>,IChildrenOfInputgroup<IDatebox>,IComponent<IDatebox>,IDateTimeFormatInputElement<IDatebox>,IFormatInputElement<IDatebox,,Date> IHtmlBasedComponent<IDatebox>,IInputElement<IDatebox,,Date> IReadonly<IDatebox>,IXulElement<IDatebox>
Datebox component
An edit box for holding a date.
The default format (IFormatInputElement.getFormat()) depends on DateFormats.getDateFormat(int, Locale, String)
and the current user's locale (unless IDateTimeFormatInputElement.withLocale(Locale) is assigned.
Please refer to withFormat(String) for more details.
Support @Action
| Name | Action Type |
|---|---|
| onTimeZoneChange | Denotes the time zone of the component is changed by user. |
Mouseless Entry
- Alt+DOWN to pop up the
calendar. - LEFT, RIGHT, UP and DOWN to change the selected day from the
calendar. - ENTER to activate the selection by copying the selected day to the
dateboxcontrol. - Alt+UP or ESC to give up the selection and close the
calendar.
Constraint
You could specify what value to accept for input controls by use of the
constraint attribute. It could be a combination
of no empty, no future, no past, and no today.
It also supports an interval of dates. For example,
IDatebox.ofConstraint("between 20071225 and 20071203");
IDatebox.ofConstraint("before 20071225");
IDatebox.ofConstraint("after 20071225");
Notices:
The format of the date in the constraint must be yyyMMdd. It is independent
of the locale. The date specified in the above constraints (before/after/between)
is included. For example, "before 20071225" includes December 25, 2007
and any day before it, and "after 20110305" includes March 5, 2011 and
any day after it.
Displayed Time Zones
The image below shows the new Datebox functionality which allows the user to change the time zone to other predefined time zones.
IDatebox.ofFormat("M/d/yy KK:mm:ss a").withWidth("150px")
.withDisplayedTimeZones("GMT+12", "GMT+8").withTimeZone("GMT+8")
.withTimeZonesReadonly(false)
Format
You are able to format the field by providing specifying the attribute
with a formatting string. The default value is null.
When the formatting of the datebox is null, it means the date will be outputted
using the format yyyy/MM/dd.
IDatebox.ofFormat("MM/dd/yyyy");
Length Option
In addition to specifying the format explicitly, you could specify the length option.
It supports four different length options mentioned at DateFormat,
such as short, medium, long, and full.
In addition, you could specify the format for both date and time by using the syntax:
withFormat("option_for_date+option_for_time")
For example,
IDatebox.ofFormat("medium+full")
Multiple-Eras Calendar
Datebox can display some multiple-eras calendar systems including:
- ROC (Taiwan):
withLocale("zh-TW-u-ca-roc"); - Japan:
withLocale("ja-JP-u-ca-japanese"); - Buddhist:
withLocale("th-TH-u-ca-buddhist");
Position
By default, the popup position is set to after_start, for other
possible popup positions please refer to IPopupBase.Position
The First Day of the Week
The first day of the week is decided by the locale (actually the return value of
the getFirstDayOfWeek method in the Calendar).
You can also control the first day of the week by the use of the session attribute
and the library property. Please refer to The First Day of the Week for details.
2DigitYearStart
You can control the 2DigitYearStart by the use of the library property, for example,
<library-property>
<name>org.zkoss.web.preferred.2DigitYearStart</name>
<value>1950</value>
</library-property>
- Author:
- katherine
- See Also:
-
Datebox
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBuilds instances of typeIDatebox.static classBuilds an updater of typeIDateboxforUiAgent.smartUpdate(Locator, SmartUpdater). -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanReturns whether to auto close the datebox popup after changing the timezone.default intgetCols()Returns the cols which determines the visible width, in characters.Returns the default datetime if the value is empty.Returns a list of the time zones that will be displayed at the client and allow user to select.default Stringdefault StringReturns the level that a user can select.default booleanReturns whether enable to show the link that jump to today in day viewdefault StringReturns the label of the link that jump to today in day viewdefault StringReturns the client widget class.default booleanReturns whether the button (on the right of the timebox) is visible.default booleanReturns whether date/time parsing is to be lenient or not.default booleanReturns whether date/time should be strict or not.default booleanReturns whether the list of the time zones to display is readonly.default booleanReturns whether enable to show the week number in the current calendar or not.static IDateboxReturn the instance of the given format and date.static IDateboxReturn the instance of the given format and date.static IDateboxReturn the instance of the given date.static IDateboxReturn the instance of the given date.static ITimeboxofCols(int cols) Returns the instance with the given cols.static IDateboxofConstraint(String constraint) Returns the instance with the given constraint.static IDateboxReturns the instance with the given format.static IDateboxReturns the instance with the given id.static IDateboxReturns the instance with the given locale.static IDateboxReturns the instance with the given locale.withButtonVisible(boolean buttonVisible) Returns a copy ofthisimmutable component with the specifiedbuttonVisible.withClosePopupOnTimezoneChange(boolean closePopupOnTimezoneChange) Returns a copy ofthisimmutable component with the specifiedclosePopupOnTimezoneChange.withDefaultDateTime(LocalDateTime defaultDateTime) Returns a copy ofthisimmutable component with the specifieddefaultDateTime.withDisplayedTimeZones(Iterable<? extends TimeZone> displayedTimeZones) Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.default IDateboxwithDisplayedTimeZones(String displayedTimeZones) Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.default IDateboxwithDisplayedTimeZones(String... displayedTimeZones) Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.default IDateboxwithDisplayedTimeZones(TimeZone... displayedTimeZones) Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.withFormat(String format) Returns a copy ofthisimmutable component with the specifiedformat.withLenient(boolean lenient) Returns a copy ofthisimmutable component with the specifiedlenient.withPosition(String position) Returns a copy ofthisimmutable component with the specifiedposition.default IDateboxwithPosition(IPopupBase.Position position) Returns a copy ofthisimmutable component with the specifiedposition.withSelectLevel(String selectLevel) Returns a copy ofthisimmutable component with the specifiedselectLevel.withShowTodayLink(boolean showTodayLink) Returns a copy ofthisimmutable component with the specifiedshowTodayLink.withStrictDate(boolean strictDate) Returns a copy ofthisimmutable component with the specifiedstrictDate.withTimeZonesReadonly(boolean timeZonesReadonly) Returns a copy ofthisimmutable component with the specifiedtimeZonesReadonly.withTodayLinkLabel(String todayLinkLabel) Returns a copy ofthisimmutable component with the specifiedtodayLinkLabel.withWeekOfYear(boolean weekOfYear) Returns a copy ofthisimmutable component with the specifiedweekOfYear.Methods inherited from interface org.zkoss.stateless.sul.IComponent
getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverridesMethods inherited from interface org.zkoss.stateless.sul.IDateTimeFormatInputElement
getLocale, getTimeZone, getValueInLocalDate, getValueInLocalDateTime, getValueInLocalTime, getValueInZonedDateTime, withLocale, withLocale, withTimeZone, withTimeZone, withValue, withValueInLocalDate, withValueInLocalDateTime, withValueInLocalTime, withValueInZonedDateTimeMethods inherited from interface org.zkoss.stateless.sul.IFormatInputElement
getFormatMethods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent
getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withSkeleton, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndexMethods inherited from interface org.zkoss.stateless.sul.IInputElement
getConstraint, getErrorboxIconSclass, getErrorboxSclass, getErrorMessage, getInputAttributes, getInstant, getMaxlength, getName, getPlaceholder, getValue, isDisabled, isInplace, withCols, withConstraint, withDisabled, withErrorboxIconSclass, withErrorboxSclass, withErrorMessage, withInplace, withInputAttributes, withInstant, withMaxlength, withName, withPlaceholderMethods inherited from interface org.zkoss.stateless.sul.IReadonly
isReadonly, withReadonlyMethods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
Field Details
-
DEFAULT
Constant for default attributes of this immutable component.
-
-
Method Details
-
getWidgetClass
Returns the client widget class.Default:
"zul.db.Datebox"- Specified by:
getWidgetClassin interfaceIComponent<IDatebox>
-
getDisplayedTimeZones
Returns a list of the time zones that will be displayed at the client and allow user to select.Default:
null -
withDisplayedTimeZones
Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.Sets a list of the time zones that will be displayed at the client and allow user to select.
If the
IDateTimeFormatInputElement.getTimeZone()is null, the first time zone in the list is assumed.- Parameters:
displayedTimeZones- A list of the time zones to display.Default:
null.- Returns:
- A modified copy of the
thisobject
-
withDisplayedTimeZones
Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.Sets a list of the time zones that will be displayed at the client and allow user to select.
If the
IDateTimeFormatInputElement.getTimeZone()is null, the first time zone in the list is assumed.- Parameters:
displayedTimeZones- A list of the time zones to display.Default:
null.- Returns:
- A modified copy of the
thisobject
-
withDisplayedTimeZones
Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.Sets a list of the time zones that will be displayed at the client and allow user to select.
If the
IDateTimeFormatInputElement.getTimeZone()is null, the first time zone in the list is assumed.- Parameters:
displayedTimeZones- A list of the time zones to display.Default:
null.- Returns:
- A modified copy of the
thisobject
-
withDisplayedTimeZones
Returns a copy ofthisimmutable component with the specifieddisplayedTimeZones.Sets a list of the time zones that will be displayed at the client and allow user to select.
If the
IDateTimeFormatInputElement.getTimeZone()is null, the first time zone in the list is assumed.- Parameters:
displayedTimeZones- A list of the time zones to display.Default:
null.- Returns:
- A modified copy of the
thisobject
-
getDefaultDateTime
Returns the default datetime if the value is empty.Default:
null(means current datetime) -
withDefaultDateTime
Returns a copy ofthisimmutable component with the specifieddefaultDateTime.Sets the default datetime if the value is empty.
- Parameters:
defaultDateTime- Default datetime. null means current datetime.Default:
null.- Returns:
- A modified copy of the
thisobject
-
isButtonVisible
default boolean isButtonVisible()Returns whether the button (on the right of the timebox) is visible.Default:
true. -
withButtonVisible
Returns a copy ofthisimmutable component with the specifiedbuttonVisible.Sets whether the button (on the right of the timebox) is visible.
- Parameters:
buttonVisible-falseto disable the button visibility.Default:
true.- Returns:
- A modified copy of the
thisobject
-
isLenient
default boolean isLenient()Returns whether date/time parsing is to be lenient or not.With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match this object's format. With strict parsing, inputs must match this object's format.
Default:
true -
withLenient
Returns a copy ofthisimmutable component with the specifiedlenient.Sets whether date/time parsing is to be lenient or not.
- Parameters:
lenient-falseto disable date/time parsing is to be lenient.Default:
true.- Returns:
- A modified copy of the
thisobject
-
isTimeZonesReadonly
default boolean isTimeZonesReadonly()Returns whether the list of the time zones to display is readonly. If readonly, the user cannot change the time zone at the client.Default:
false -
withTimeZonesReadonly
Returns a copy ofthisimmutable component with the specifiedtimeZonesReadonly.Sets whether the list of the time zones to display is readonly. If readonly, the user cannot change the time zone at the client.
- Parameters:
timeZonesReadonly-trueto make time zones options display as readonly.Default:
false.- Returns:
- A modified copy of the
thisobject
-
isWeekOfYear
default boolean isWeekOfYear()Returns whether enable to show the week number in the current calendar or not.Default:
false -
withWeekOfYear
Returns a copy ofthisimmutable component with the specifiedweekOfYear.Sets whether enable to show the week number in the current calendar or not. (ZK EE only)
- Parameters:
weekOfYear-trueto show the week number in the current calendar.Default:
false.- Returns:
- A modified copy of the
thisobject
-
getPosition
- Returns:
- the datebox popup position
-
withPosition
Returns a copy ofthisimmutable component with the specifiedposition.Position the popup datebox to the specified location.
- Parameters:
position- Where to position. Default:after_startAllowed values:- before_start
the component appears above the anchor, aligned to the left. - before_center
the component appears above the anchor, aligned to the center. - before_end
the component appears above the anchor, aligned to the right. - after_start
the component appears below the anchor, aligned to the left. - after_center
the component appears below the anchor, aligned to the center. - after_end
the component appears below the anchor, aligned to the right. - start_before
the component appears to the left of the anchor, aligned to the top. - start_center
the component appears to the left of the anchor, aligned to the middle. - start_after
the component appears to the left of the anchor, aligned to the bottom. - end_before
the component appears to the right of the anchor, aligned to the top. - end_center
the component appears to the right of the anchor, aligned to the middle. - end_after
the component appears to the right of the anchor, aligned to the bottom. - overlap/top_left
the component overlaps the anchor, with anchor and element aligned at top-left. - top_center
the component overlaps the anchor, with anchor and element aligned at top-center. - overlap_end/top_right
the component overlaps the anchor, with anchor and element aligned at top-right. - middle_left
the component overlaps the anchor, with anchor and element aligned at middle-left. - middle_center
the component overlaps the anchor, with anchor and element aligned at middle-center. - middle_right
the component overlaps the anchor, with anchor and element aligned at middle-right. - overlap_before/bottom_left
the component overlaps the anchor, with anchor and element aligned at bottom-left. - bottom_center
the component overlaps the anchor, with anchor and element aligned at bottom-center. - overlap_after/bottom_right
the component overlaps the anchor, with anchor and element aligned at bottom-right. - at_pointer
the component appears with the upper-left aligned with the mouse cursor. - after_pointer
the component appears with the top aligned with the bottom of the mouse cursor, with the left side of the component at the horizontal position of the mouse cursor.
- before_start
- Returns:
- A modified copy of the
thisobject
-
withPosition
Returns a copy ofthisimmutable component with the specifiedposition.Position the popup datebox to the specified location.
- Parameters:
position- Where to position. Default:IPopupBase.Position.AFTER_START- Returns:
- A modified copy of the
thisobject
-
isStrictDate
default boolean isStrictDate()Returns whether date/time should be strict or not.Default:
false. -
withStrictDate
Returns a copy ofthisimmutable component with the specifiedstrictDate.Sets whether date/time should be strict or not.
If true, any invalid input like "Jan 0" or "Nov 31" would be refused.
If false, it won't be checked and let lenient parsing decide.
- Parameters:
strictDate-trueto make date/time be strict.Default:
false.- Returns:
- A modified copy of the
thisobject
-
getShowTodayLink
default boolean getShowTodayLink()Returns whether enable to show the link that jump to today in day viewDefault:
false -
withShowTodayLink
Returns a copy ofthisimmutable component with the specifiedshowTodayLink.Sets whether enable to show the link that jump to today in day view
- Parameters:
showTodayLink-trueto show a link to jump to today.Default:
false.- Returns:
- A modified copy of the
thisobject
-
getTodayLinkLabel
Returns the label of the link that jump to today in day viewDefault:
"Today" -
withTodayLinkLabel
Returns a copy ofthisimmutable component with the specifiedtodayLinkLabel.Sets the label of the link that jump to today in day view.
- Parameters:
todayLinkLabel- The label of the link to jump to today.Default:
"Today".- Returns:
- A modified copy of the
thisobject
-
getSelectLevel
Returns the level that a user can select.Default:
"day" -
withSelectLevel
Returns a copy ofthisimmutable component with the specifiedselectLevel.Sets the level that a user can select.
- Parameters:
selectLevel- The level that a user can select.Default:
"day".- Returns:
- A modified copy of the
thisobject
-
getClosePopupOnTimezoneChange
default boolean getClosePopupOnTimezoneChange()Returns whether to auto close the datebox popup after changing the timezone.Default:
true -
withClosePopupOnTimezoneChange
Returns a copy ofthisimmutable component with the specifiedclosePopupOnTimezoneChange.Sets whether to auto close the datebox popup after changing the timezone.
- Parameters:
closePopupOnTimezoneChange- Whether to auto close the datebox popup after changing the timezoneDefault:
true.- Returns:
- A modified copy of the
thisobject
-
getCols
default int getCols()Returns the cols which determines the visible width, in characters.Default:
11(non-positive means the same as browser's default).- Specified by:
getColsin interfaceIInputElement<IDatebox,Date>
-
withFormat
Returns a copy ofthisimmutable component with the specifiedformat.Sets the date format.
You could specify one of the following reserved words, and
DateFormats.getDateFormat(int, Locale, String)orDateFormats.getDateTimeFormat(int, int, java.util.Locale, java.lang.String)will be used to retrieve the real format.short DateFormats.getDateFormat(int, Locale, String)withDateFormat.SHORTmedium DateFormats.getDateFormat(int, Locale, String)withDateFormat.MEDIUMlong DateFormats.getDateFormat(int, Locale, String)withDateFormat.LONGfull DateFormats.getDateFormat(int, Locale, String)withDateFormat.FULLTo specify a date/time format, you could specify two reserved words, separated by a plus. For example, "medium+short" means
DateFormats.getDateTimeFormat(int, int, java.util.Locale, java.lang.String)with the medium date styling and the short time styling.In additions, the format could be a combination of the following pattern letters:
Letter Date or Time Component Presentation Examples GEra designator Text ADyYear Year 1996;96MMonth in year Month July;Jul;07wWeek in year (starting at 1) Number 27WWeek in month (starting at 1) Number 2DDay in year (starting at 1) Number 189dDay in month (starting at 1) Number 10FDay of week in month Number 2EDay in week Text Tuesday;Tue- Specified by:
withFormatin interfaceIFormatInputElement<IDatebox,Date> - Parameters:
format- The format of the datebox.Default:
Datebox.DEFAULT_FORMAT.- Returns:
- A modified copy of the
thisobject
-
of
Return the instance of the given date.- Parameters:
date- The date to indicate the value for datebox.
-
of
Return the instance of the given date.- Parameters:
date- The date to indicate the value for datebox.
-
of
Return the instance of the given format and date.- Parameters:
format- The format of the dateboxdate- The date to indicate the value for datebox.
-
of
Return the instance of the given format and date.- Parameters:
format- The format of the dateboxdate- The date to indicate the value for datebox.
-
ofLocale
Returns the instance with the given locale.- Parameters:
locale- The datebox locale
-
ofLocale
Returns the instance with the given locale.- Parameters:
locale- The datebox locale
-
ofCols
Returns the instance with the given cols.- Parameters:
cols- The cols which determines the visible width
-
ofConstraint
Returns the instance with the given constraint.- Parameters:
constraint- The datebox constraint
-
ofFormat
Returns the instance with the given format.- Parameters:
format- The datebox format
-
ofId
Returns the instance with the given id.- Parameters:
id- The id to identify this component
-