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() . |
AbstractComponent.Children
_locale, _tzone
_value
_zclass
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
Constructor and Description |
---|
Datebox() |
Datebox(java.util.Date date)
Constructor with a given date.
|
Datebox(java.time.LocalDate value)
Constructor with a given date.
|
Datebox(java.time.LocalDateTime value)
Constructor with a given date.
|
Datebox(java.time.LocalTime value)
Constructor with a given date.
|
Datebox(java.time.ZonedDateTime value)
Constructor with a given date.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the calendar if it was dropped down.
|
protected java.lang.Object |
coerceFromString(java.lang.String value)
Coerces the value passed to
InputElement.setText(java.lang.String) . |
protected java.lang.String |
coerceToString(java.lang.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 java.text.DateFormat |
getDateFormat(java.lang.String fmt)
Returns the date format of the specified format
Default: it uses SimpleDateFormat to format the date.
|
java.time.LocalDateTime |
getDefaultDateTime()
Returns the default datetime if the value is empty.
|
protected java.lang.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. |
java.util.List<java.util.TimeZone> |
getDisplayedTimeZones()
Returns a list of the time zones that will be displayed at the
client and allow user to select.
|
java.lang.Object |
getExtraCtrl()
Returns the client control for this component.
|
protected java.lang.String |
getLocalizedFormat()
Returns the localized format, which is used when constructing a datebox.
|
java.lang.String |
getPosition() |
PropertyAccess |
getPropertyAccess(java.lang.String prop)
Returns the corresponding property access object from the given property
name, if any.
|
java.lang.String |
getRealFormat()
Returns the real format, i.e., the combination of the format patterns,
such as yyyy-MM-dd.
|
java.lang.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
Default: false
|
java.lang.String |
getTodayLinkLabel()
Returns the label of the link that jump to today in day view
Default: Today
|
java.lang.String |
getZclass()
Returns the ZK Cascading Style class(es) for this component.
|
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(ContentRenderer renderer)
Renders the content of this component, excluding the enclosing
tags and children.
|
void |
service(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(java.lang.String constr) |
void |
setDefaultDateTime(java.time.LocalDateTime defaultDateTime)
Sets the default datetime if the value is empty.
|
void |
setDisplayedTimeZones(java.util.List<java.util.TimeZone> dtzones)
Sets a list of the time zones that will be displayed at the
client and allow user to select.
|
void |
setDisplayedTimeZones(java.lang.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(java.lang.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(java.lang.String position)
Position the popup datebox to the specified location.
|
void |
setSelectLevel(java.lang.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(java.util.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(java.lang.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(java.lang.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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
invalidatePartial
public Datebox()
public Datebox(java.util.Date date) throws 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.WrongValueException
public Datebox(java.time.ZonedDateTime value) throws 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.WrongValueException
public Datebox(java.time.LocalDateTime value) throws 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.WrongValueException
public Datebox(java.time.LocalDate value) throws 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.WrongValueException
public Datebox(java.time.LocalTime value) throws 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.WrongValueException
public void setWeekOfYear(boolean weekOfYear)
public boolean isWeekOfYear()
Default: false
public void setStrictDate(boolean strictDate)
public boolean isStrictDate()
Default: false.
protected java.lang.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 java.lang.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 java.lang.String getPosition()
public void setPosition(java.lang.String position)
position
- where to position. Default: after_start
Allowed values:
public void setFormat(java.lang.String format) throws 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
WrongValueException
public static int toStyle(java.lang.String format)
public java.lang.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(java.util.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 java.util.List<java.util.TimeZone> getDisplayedTimeZones()
Default: null
public void setDisplayedTimeZones(java.util.List<java.util.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(java.lang.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(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 ComponentCtrl
service
in class InputElement
everError
- whether any error ever occurred before
processing this request.AbstractComponent.setAuService(org.zkoss.zk.au.AuService)
public java.lang.Object getExtraCtrl()
HtmlBasedComponent
Default: creates an instance of HtmlBasedComponent.ExtraCtrl
.
getExtraCtrl
in interface ComponentCtrl
getExtraCtrl
in class HtmlBasedComponent
Cropper
.ComponentCtrl.getExtraCtrl()
public void setConstraint(java.lang.String constr)
setConstraint
in class InputElement
constr
- a list of constraints separated by comma.
Example: "between 20071012 and 20071223", "before 20080103"protected java.lang.Object coerceFromString(java.lang.String value) throws 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
WrongValueException
protected java.lang.String coerceToString(java.lang.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 java.text.DateFormat getDateFormat(java.lang.String fmt)
Default: it uses SimpleDateFormat to format the date.
fmt
- the pattern.public java.lang.String getZclass()
HtmlBasedComponent
AbstractComponent.getMold()
).
Default: null (the default value depends on element).
HtmlBasedComponent.setZclass(java.lang.String)
) will completely replace the default style
of a component. In other words, the default style of a component
is associated with the default value of HtmlBasedComponent.getZclass()
.
Once it is changed, the default style won't be applied at all.
If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String)
instead.
getZclass
in class HtmlBasedComponent
HtmlBasedComponent.getSclass()
public boolean getShowTodayLink()
Default: false
public void setShowTodayLink(boolean showTodayLink)
showTodayLink
- show or hiddenpublic java.lang.String getTodayLinkLabel()
Default: Today
public void setTodayLinkLabel(java.lang.String todayLinkLabel)
todayLinkLabel
- today link labelpublic java.time.LocalDateTime getDefaultDateTime()
Default: null (means current datetime)
public void setDefaultDateTime(java.time.LocalDateTime defaultDateTime)
defaultDateTime
- Default datetime. null means current datetime.public java.lang.String getSelectLevel()
Default: "day"
public void setSelectLevel(java.lang.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 PropertyAccess getPropertyAccess(java.lang.String prop)
ComponentCtrl
getPropertyAccess
in interface ComponentCtrl
getPropertyAccess
in class DateTimeFormatInputElement
prop
- the name of the propertyprotected void renderProperties(ContentRenderer renderer) throws java.io.IOException
HtmlBasedComponent
renderProperties
in class DateTimeFormatInputElement
java.io.IOException
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.