|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.zk.ui.AbstractComponent org.zkoss.zk.ui.HtmlBasedComponent org.zkoss.zul.impl.XulElement org.zkoss.zul.impl.InputElement org.zkoss.zul.impl.FormatInputElement org.zkoss.zul.Datebox
public class Datebox
An edit box for holding a date.
The default format (FormatInputElement.getFormat()
) depends on DateFormats.getDateFormat(int, java.util.Locale, java.lang.String)
and the current user's locale (unless setLocale(java.util.Locale)
is assigned.
Please refer to setFormat(java.lang.String)
for more details.
Default getZclass()
: z-datebox.(since 3.5.0)
Nested Class Summary | |
---|---|
protected class |
Datebox.ExtraCtrl
A utility class to implement HtmlBasedComponent.getExtraCtrl() . |
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent |
---|
AbstractComponent.Children |
Field Summary |
---|
Fields inherited from class org.zkoss.zul.impl.InputElement |
---|
_value |
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
_zclass |
Fields inherited from interface org.zkoss.zk.ui.Component |
---|
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE |
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl |
---|
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE |
Constructor Summary | |
---|---|
Datebox()
|
|
Datebox(java.util.Date date)
Constructor with a given date. |
Method Summary | |
---|---|
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) . |
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. |
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. |
java.util.Locale |
getLocale()
Returns the locale associated with this datebox, or null if Locales.getCurrent() is preferred. |
protected java.lang.String |
getLocalizedFormat()
Returns the localized format, which is used when constructing a datebox. |
java.lang.String |
getRealFormat()
Returns the real format, i.e., the combination of the format patterns, such as yyyy-MM-dd. |
boolean |
getShowTodayLink()
Returns whether enable to show the link that jump to today in day view Default: false |
java.util.TimeZone |
getTimeZone()
Returns the time zone that this date box belongs to, or null if the default time zone is used. |
java.util.Date |
getValue()
Returns the value (in Date), might be null unless a constraint stops it. |
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 |
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. |
protected java.lang.Object |
marshall(java.lang.Object value)
Marshall value to be sent to the client if needed. |
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 |
setCompact(boolean compact)
Deprecated. As of release 5.0.0, it is no longer supported. |
void |
setConstraint(java.lang.String constr)
|
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 |
setLocale(java.util.Locale locale)
Sets the locale used to identify the format of this datebox. |
void |
setLocale(java.lang.String locale)
Sets the locale used to identify the format of this datebox. |
void |
setOpen(boolean open)
Drops down or closes the calendar to select a date. |
void |
setShowTodayLink(boolean showTodayLink)
Sets whether enable to show the link that jump to today in day view |
void |
setTimeZone(java.lang.String id)
Sets the time zone that this date box belongs to, or null if the default time zone is used. |
void |
setTimeZone(java.util.TimeZone tzone)
Sets the time zone that this date box 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 |
setValue(java.util.Date value)
Sets the value (in Date). |
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. |
protected java.lang.Object |
unmarshall(java.lang.Object value)
Unmarshall value returned from client if needed. |
Methods inherited from class org.zkoss.zul.impl.FormatInputElement |
---|
getFormat |
Methods inherited from class org.zkoss.zul.impl.InputElement |
---|
checkUserError, clearErrorMessage, clearErrorMessage, clone, getCols, getConstraint, getErrorMessage, getInstant, getMaxlength, getName, getPlaceholder, getRawText, getRawValue, getTabindex, getTargetValue, getText, getType, isChildable, isDisabled, isInplace, isMultiline, isReadonly, isValid, onWrongValue, select, setCols, setConstraint, setDisabled, setErrorMessage, setInplace, setInstant, setMaxlength, setName, setPlaceholder, setRawValue, setReadonly, setSelectedText, setSelectionRange, setTabindex, setText, setValueDirectly, showCustomError, validate |
Methods inherited from class org.zkoss.zul.impl.XulElement |
---|
getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip |
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
focus, getAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeightDirectly, setHflex, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTooltiptext, setTop, setTopDirectly, setVflex, setWidth, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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
Method Detail |
---|
public void setWeekOfYear(boolean weekOfYear)
public boolean isWeekOfYear()
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.util.Date getValue() throws WrongValueException
WrongValueException
- if user entered a wrong valuepublic void setValue(java.util.Date value) throws WrongValueException
value
- the date to be assigned to this datebox.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
- if value is wrongpublic 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 java.util.TimeZone getTimeZone()
The default time zone is determined by TimeZones.getCurrent()
.
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.
public void setTimeZone(java.lang.String id)
The default time zone is determined by TimeZones.getCurrent()
.
id
- the time zone's ID, such as "America/Los_Angeles".
The time zone will be retrieved by calling TimeZone.getTimeZone(id).public java.util.List<java.util.TimeZone> getDisplayedTimeZones()
Default: null
public void setDisplayedTimeZones(java.util.List<java.util.TimeZone> dtzones)
If the 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 java.util.Locale getLocale()
Locales.getCurrent()
is preferred.
public void setLocale(java.util.Locale locale)
Default: null (i.e., Locales.getCurrent()
, the current locale
is assumed)
public void setLocale(java.lang.String locale)
Default: null (i.e., Locales.getCurrent()
, the current locale
is assumed)
public void setOpen(boolean open)
open()
,
close()
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 marshall(java.lang.Object value)
InputElement
Overrides it if the value to be sent to the client is not JSON Compatible.
marshall
in class InputElement
value
- the value to be sent to the client
protected java.lang.Object unmarshall(java.lang.Object value)
InputElement
Overrides it if the value returned is not JSON Compatible.
unmarshall
in class InputElement
value
- the value returned from client
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 hiddenprotected void renderProperties(ContentRenderer renderer) throws java.io.IOException
HtmlBasedComponent
See also ZK Client-side Reference: Property Rendering
renderProperties
in class FormatInputElement
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |