public class Datebox extends DateTimeFormatInputElement
The default format (FormatInputElement.getFormat()
) depends on DateFormats.getDateFormat(int, java.util.Locale, java.lang.String)
and the current user's locale (unless DateTimeFormatInputElement.setLocale(java.util.Locale)
is assigned.
Please refer to setFormat(java.lang.String)
for more details.
Default getZclass()
: z-datebox.(since 3.5.0)
Modifier and Type | Class and Description |
---|---|
protected class |
Datebox.ExtraCtrl
A utility class to implement
HtmlBasedComponent.getExtraCtrl() . |
_locale, _tzone
_value
Constructor and Description |
---|
Datebox() |
Datebox(Date date)
Constructor with a given date.
|
Datebox(LocalDate value)
Constructor with a given date.
|
Datebox(LocalDateTime value)
Constructor with a given date.
|
Datebox(LocalTime value)
Constructor with a given date.
|
Datebox(ZonedDateTime value)
Constructor with a given date.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the calendar if it was dropped down.
|
protected Object |
coerceFromString(String value)
Coerces the value passed to
InputElement.setText(java.lang.String) . |
protected String |
coerceToString(Object value)
Coerces the value passed to
InputElement.setText(java.lang.String) . |
boolean |
getClosePopupOnTimezoneChange()
Returns whether to auto close the datebox popup after changing the timezone.
|
protected DateFormat |
getDateFormat(String fmt)
Returns the date format of the specified format
|
LocalDateTime |
getDefaultDateTime()
Returns the default datetime if the value is empty.
|
protected String |
getDefaultFormat()
Returns the default format, which is used when constructing a datebox,
or when
setFormat(java.lang.String) is called with null or empty. |
List<TimeZone> |
getDisplayedTimeZones()
Returns a list of the time zones that will be displayed at the
client and allow user to select.
|
Object |
getExtraCtrl() |
protected String |
getLocalizedFormat()
Returns the localized format, which is used when constructing a datebox.
|
String |
getPosition() |
org.zkoss.zk.ui.sys.PropertyAccess |
getPropertyAccess(String prop) |
String |
getRealFormat()
Returns the real format, i.e., the combination of the format patterns,
such as yyyy-MM-dd.
|
String |
getSelectLevel()
Returns the level that a user can select.
|
boolean |
getShowTodayLink()
Returns whether enable to show the link that jump to today in day view
|
String |
getTodayLinkLabel()
Returns the label of the link that jump to today in day view
|
String |
getZclass() |
boolean |
isButtonVisible()
Returns whether the button (on the right of the textbox) is visible.
|
boolean |
isCompact()
Deprecated.
As of release 5.0.0, it is no longer supported.
|
boolean |
isLenient()
Returns whether or not date/time parsing is to be lenient.
|
boolean |
isStrictDate()
Returns whether or not date/time should be strict.
|
boolean |
isTimeZonesReadonly()
Returns whether the list of the time zones to display is readonly.
|
boolean |
isWeekOfYear()
Returns whether enable to show the week number in the current calendar or not.
|
void |
open()
Drops down the calendar to select a date.
|
protected void |
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) |
void |
service(org.zkoss.zk.au.AuRequest request,
boolean everError)
Processes an AU request.
|
void |
setButtonVisible(boolean visible)
Sets whether the button (on the right of the textbox) is visible.
|
void |
setClosePopupOnTimezoneChange(boolean closePopupOnTimezoneChange)
Sets whether to auto close the datebox popup after changing the timezone.
|
void |
setCompact(boolean compact)
Deprecated.
As of release 5.0.0, it is no longer supported.
|
void |
setConstraint(String constr) |
void |
setDefaultDateTime(LocalDateTime defaultDateTime)
Sets the default datetime if the value is empty.
|
void |
setDisplayedTimeZones(List<TimeZone> dtzones)
Sets a list of the time zones that will be displayed at the
client and allow user to select.
|
void |
setDisplayedTimeZones(String dtzones)
Sets a concatenation of a list of the time zones' ID, separated by comma,
that will be displayed at the client and allow user to select.
|
void |
setFormat(String format)
Sets the date format.
|
void |
setLenient(boolean lenient)
Sets whether or not date/time parsing is to be lenient.
|
void |
setOpen(boolean open)
Drops down or closes the calendar to select a date.
|
void |
setPosition(String position)
Position the popup datebox to the specified location.
|
void |
setSelectLevel(String selectLevel)
Sets the level that a user can select.
|
void |
setShowTodayLink(boolean showTodayLink)
Sets whether enable to show the link that jump to today in day view
|
void |
setStrictDate(boolean strictDate)
Sets whether or not date/time should be strict.
|
void |
setTimeZone(TimeZone tzone)
Sets the time zone that this component belongs to, or null if
the default time zone is used.
|
void |
setTimeZonesReadonly(boolean readonly)
Sets whether the list of the time zones to display is readonly.
|
void |
setTodayLinkLabel(String todayLinkLabel)
Sets the label of the link that jump to today in day view
|
void |
setWeekOfYear(boolean weekOfYear)
Sets whether enable to show the week number in the current calendar or
not.
|
static int |
toStyle(String format)
Returns the styling index, or -111 if not matched.
|
getLocale, getTimeZone, getValue, getValueInLocalDate, getValueInLocalDateTime, getValueInLocalTime, getValueInZonedDateTime, getZoneId, setConstraint, setLocale, setLocale, setTimeZone, setValue, setValueInLocalDate, setValueInLocalDateTime, setValueInLocalTime, setValueInZonedDateTime, toDate, toDate, toDate, toZonedDateTime
getFormat
checkUserError, clearErrorMessage, clearErrorMessage, clone, getCols, getConstraint, getErrorboxIconSclass, getErrorboxSclass, getErrorMessage, getInputAttributes, getInstant, getMaxlength, getName, getPlaceholder, getRawText, getRawValue, getTargetValue, getText, getType, isChildable, isDisabled, isInplace, isInstant, isMultiline, isReadonly, isValid, marshall, onWrongValue, select, setCols, setDisabled, setErrorboxIconSclass, setErrorboxSclass, setErrorMessage, setInplace, setInputAttributes, setInputAttributes, setInsertedText, setInstant, setMaxlength, setName, setPlaceholder, setRawValue, setReadonly, setSelectedText, setSelectionRange, setText, setValueDirectly, showCustomError, unmarshall, validate
getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
addSclass, evalCSSFlex, focus, getAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
addAnnotation, addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, enableBindingAnnotation, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, insertBefore, invalidate, invalidatePartial, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
public Datebox()
public Datebox(Date date) throws org.zkoss.zk.ui.WrongValueException
date
- the date to be assigned to this datebox initially.TimeZones.getCurrent()
), so it is easier
to work with other libraries, such as SQL.
Dates
has a set of utilities to simplify the task.org.zkoss.zk.ui.WrongValueException
public Datebox(ZonedDateTime value) throws org.zkoss.zk.ui.WrongValueException
value
- the date to be assigned to this datebox initially.TimeZones.getCurrent()
), so it is easier
to work with other libraries, such as SQL.
Dates
has a set of utilities to simplify the task.org.zkoss.zk.ui.WrongValueException
public Datebox(LocalDateTime value) throws org.zkoss.zk.ui.WrongValueException
value
- the date to be assigned to this datebox initially.TimeZones.getCurrent()
), so it is easier
to work with other libraries, such as SQL.
Dates
has a set of utilities to simplify the task.org.zkoss.zk.ui.WrongValueException
public Datebox(LocalDate value) throws org.zkoss.zk.ui.WrongValueException
value
- the date to be assigned to this datebox initially.TimeZones.getCurrent()
), so it is easier
to work with other libraries, such as SQL.
Dates
has a set of utilities to simplify the task.org.zkoss.zk.ui.WrongValueException
public Datebox(LocalTime value) throws org.zkoss.zk.ui.WrongValueException
value
- the date to be assigned to this datebox initially.TimeZones.getCurrent()
), so it is easier
to work with other libraries, such as SQL.
Dates
has a set of utilities to simplify the task.org.zkoss.zk.ui.WrongValueException
public void setWeekOfYear(boolean weekOfYear)
public boolean isWeekOfYear()
Default: false
public void setStrictDate(boolean strictDate)
public boolean isStrictDate()
Default: false.
protected String getDefaultFormat()
setFormat(java.lang.String)
is called with null or empty.
Default: DateFormats.getDateFormat(DEFAULT, null, "yyyy/MM/dd")
(see DateFormats.getDateFormat(int, java.util.Locale, java.lang.String)
).
Though you might override this method to provide your own default format,
it is suggested to specify the format for the current thread
with DateFormats.setLocalFormatInfo(org.zkoss.text.DateFormatInfo)
.
protected String getLocalizedFormat()
You might override this method to provide your own localized format.
public boolean isLenient()
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.
public void setLenient(boolean lenient)
Default: true.
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.
public boolean isCompact()
public void setCompact(boolean compact)
public boolean isButtonVisible()
Default: true.
public void setButtonVisible(boolean visible)
public String getPosition()
public void setPosition(String position)
position
- where to position. Default: after_start
Allowed values:
public void setFormat(String format) throws org.zkoss.zk.ui.WrongValueException
If null or empty is specified, getDefaultFormat()
is assumed.
Since 5.0.7, you could specify one of the following reserved words,
and DateFormats.getDateFormat(int, java.util.Locale, java.lang.String)
or DateFormats.getDateTimeFormat(int, int, java.util.Locale, java.lang.String)
will be used to retrieve the real format.
short | DateFormats.getDateFormat(int, java.util.Locale, java.lang.String) with DateFormat.SHORT |
medium | DateFormats.getDateFormat(int, java.util.Locale, java.lang.String) with DateFormat.MEDIUM |
long | DateFormats.getDateFormat(int, java.util.Locale, java.lang.String) with DateFormat.LONG |
full | DateFormats.getDateFormat(int, java.util.Locale, java.lang.String) with DateFormat.FULL |
To 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 |
---|---|---|---|
G
| Era designator | Text | AD
|
y
| Year | Year | 1996 ; 96
|
M
| Month in year | Month | July ; Jul ; 07
|
w
| Week in year (starting at 1) | Number | 27
|
W
| Week in month (starting at 1) | Number | 2
|
D
| Day in year (starting at 1) | Number | 189
|
d
| Day in month (starting at 1) | Number | 10
|
F
| Day of week in month | Number | 2
|
E
| Day in week | Text | Tuesday ; Tue
|
setFormat
in class FormatInputElement
org.zkoss.zk.ui.WrongValueException
public static int toStyle(String format)
public String getRealFormat()
As described in setFormat(java.lang.String)
, a developer could specify
an abstract name, such as short, or an empty string as the format,
and this method will convert it to a real date/time format.
getRealFormat
in class FormatInputElement
public void setTimeZone(TimeZone tzone)
The default time zone is determined by TimeZones.getCurrent()
.
Notice that if getDisplayedTimeZones()
was called with
a non-empty list, the time zone must be one of it.
Otherwise (including tzone is null),
the first timezone is selected.
setTimeZone
in class DateTimeFormatInputElement
public List<TimeZone> getDisplayedTimeZones()
Default: null
public void setDisplayedTimeZones(List<TimeZone> dtzones)
If the DateTimeFormatInputElement.getTimeZone()
is null,
the first time zone in the list is assumed.
dtzones
- a list of the time zones to display.
If empty, it assumed to be null.public void setDisplayedTimeZones(String dtzones)
The time zone is retrieved by calling TimeZone.getTimeZone().
dtzones
- a concatenation of a list of the timezones' ID, such as
"America/Los_Angeles,GMT+8"
setDisplayedTimeZones(List)
public boolean isTimeZonesReadonly()
public void setTimeZonesReadonly(boolean readonly)
public void setOpen(boolean open)
public void open()
public void close()
public void service(org.zkoss.zk.au.AuRequest request, boolean everError)
Default: in addition to what are handled by HtmlBasedComponent.service(org.zkoss.zk.au.AuRequest, boolean)
,
it also handles onTimeZoneChange, onChange, onChanging and onError.
service
in interface org.zkoss.zk.ui.sys.ComponentCtrl
service
in class InputElement
public Object getExtraCtrl()
getExtraCtrl
in interface org.zkoss.zk.ui.sys.ComponentCtrl
getExtraCtrl
in class org.zkoss.zk.ui.HtmlBasedComponent
public void setConstraint(String constr)
setConstraint
in class InputElement
constr
- a list of constraints separated by comma.
Example: "between 20071012 and 20071223", "before 20080103"protected Object coerceFromString(String value) throws org.zkoss.zk.ui.WrongValueException
InputElement
InputElement.setText(java.lang.String)
.
Deriving note:
If you want to store the value in other type, say BigDecimal,
you have to override InputElement.coerceToString(java.lang.Object)
and InputElement.coerceFromString(java.lang.String)
to convert between a string and your targeting type.
Moreover, when Textbox
is called, it calls this method
with value = null. Derives shall handle this case properly.
coerceFromString
in class InputElement
org.zkoss.zk.ui.WrongValueException
protected String coerceToString(Object value)
InputElement
InputElement.setText(java.lang.String)
.
Default: convert null to an empty string.
Deriving note:
If you want to store the value in other type, say BigDecimal,
you have to override InputElement.coerceToString(java.lang.Object)
and InputElement.coerceFromString(java.lang.String)
to convert between a string and your targeting type.
coerceToString
in class InputElement
protected DateFormat getDateFormat(String fmt)
Default: it uses SimpleDateFormat to format the date.
fmt
- the pattern.public String getZclass()
getZclass
in class org.zkoss.zk.ui.HtmlBasedComponent
public boolean getShowTodayLink()
Default: false
public void setShowTodayLink(boolean showTodayLink)
showTodayLink
- show or hiddenpublic String getTodayLinkLabel()
Default: Today
public void setTodayLinkLabel(String todayLinkLabel)
todayLinkLabel
- today link labelpublic LocalDateTime getDefaultDateTime()
Default: null (means current datetime)
public void setDefaultDateTime(LocalDateTime defaultDateTime)
defaultDateTime
- Default datetime. null means current datetime.public String getSelectLevel()
Default: "day"
public void setSelectLevel(String selectLevel)
selectLevel
- the level that a user can selectpublic boolean getClosePopupOnTimezoneChange()
Default: true
public void setClosePopupOnTimezoneChange(boolean closePopupOnTimezoneChange)
closePopupOnTimezoneChange
- shall close the datebox popup or notpublic org.zkoss.zk.ui.sys.PropertyAccess getPropertyAccess(String prop)
getPropertyAccess
in interface org.zkoss.zk.ui.sys.ComponentCtrl
getPropertyAccess
in class DateTimeFormatInputElement
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws IOException
renderProperties
in class DateTimeFormatInputElement
IOException
Copyright © 2022. All rights reserved.