Class Daterangebox
- All Implemented Interfaces:
Serializable,Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Disable,org.zkoss.zk.ui.ext.Readonly,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl,org.zkoss.zul.ext.Constrainted
Value is a DateRange composed of a begin date and an end date.
Either end may be null when setAllowEmpty(String) permits.
Reuses SimpleDateConstraint for validation: "between A and B",
"before X", "after X", "no past", "no future",
etc. apply to both the begin and end values.
Server / client globally configurable defaults (zk.xml library properties)
org.zkoss.zul.daterangebox.numberOfMonths(default 2)org.zkoss.zul.daterangebox.hoverPreview(default true)org.zkoss.zul.daterangebox.separator(default "~")
Events
onChange and onChanging deliver a Daterangebox.RangeChangeEvent
(which extends Event), not an
InputEvent — a two-ended range cannot be carried by the single
value of an InputEvent. A server-side listener must declare its
parameter as Daterangebox.RangeChangeEvent and read
Daterangebox.RangeChangeEvent.getRange(), Daterangebox.RangeChangeEvent.getBegin() or
Daterangebox.RangeChangeEvent.getEnd(); a handler typed onChange(InputEvent),
or a ZUL EL expression reading event.value, will not match. Data
binding is unaffected: @bind/@save persist through the
value / beginValue / endValue properties rather than
the event object.
- Since:
- 11.0.0
- Author:
- peaker
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA utility class to implementHtmlBasedComponent.getExtraCtrl().static classEvent fired when the begin or end value changes (carried byonChangeandonChanging).Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo -
Field Summary
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty date range picker.Daterangebox(org.zkoss.zul.DateRange range) Constructs a date range picker with the given initial range. -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild) Rejects ZUL child nodes.voidClears the error message.Returns which endpoints may be left empty: one of"none","begin","end"or"both".Returns the placeholder for the begin input, ornullif none.Returns a defensive copy of the begin endpoint, ornullif unset.Returns the begin endpoint as aLocalDatein the component's time zone, ornullif unset.Returns the begin endpoint as aLocalDateTimein the component's time zone, ornullif unset.Returns the begin endpoint as aZonedDateTimein the component's time zone, ornullif unset.org.zkoss.zul.ConstraintReturns the activeConstraint, ornullif none is set.Returns the raw constraint string of the activeConstraintif it is aSimpleConstraint, ornullotherwise, matchingInputElement.getConstraintString().Returns the placeholder for the end input, ornullif none.Returns a defensive copy of the end endpoint, ornullif unset.Returns the end endpoint as aLocalDatein the component's time zone, ornullif unset.Returns the end endpoint as aLocalDateTimein the component's time zone, ornullif unset.Returns the end endpoint as aZonedDateTimein the component's time zone, ornullif unset.Returns the error message that is caused when user entered invalid value, or null if no error at all.Returns the raw date format pattern, ornullif none was set (in which casegetRealFormat()supplies the locale-derived fallback).Returns the additional attributes which is set bysetInputAttributes(Map<String, String> inputAttributes).Returns the locale used for month/weekday labels and the first-day-of-week, ornull(the page/current locale) if unset.intReturns the maximum number of nights (difference in calendar days) allowed between begin and end.intReturns the minimum number of nights (difference in calendar days) required between begin and end.intReturns the number of side-by-side calendar panels shown in the popup.Returns the placeholder applied to both inputs when no per-input placeholder is set, ornullif none.Returns the popup anchor position token.Returns the format actually used.Returns the explicit separator if set, otherwise the library-property default (or"~"as the final fallback).Returns the time zone used for calendar-day boundary decisions and constraint-bound parsing, ornull(the current time zone) if unset.Returns the label of the "Today" shortcut shown in the popup footer whenisShowTodayLink()is on.org.zkoss.zul.DateRangegetValue()Returns the current range as aDateRange.org.zkoss.zul.LocalDateRangeReturns the range as aLocalDateRangein the component's time zone.org.zkoss.zul.LocalDateTimeRangeReturns the range as aLocalDateTimeRangein the component's time zone.org.zkoss.zul.ZonedDateTimeRangeReturns the range as aZonedDateTimeRangein the component's time zone.booleanReturns whether the calendar drop-down button is shown to the right of the inputs.booleanReturns whether the component is disabled (no user interaction).booleanReturns whether hovering a candidate end date previews the range in the calendar.booleanReturns whether date parsing is lenient.booleanisOpen()Returns whether the calendar popup is currently open.booleanReturns whether the component is read-only (value shown but not editable).booleanReturns whether the time picker is shown.booleanReturns whether the "Today" shortcut link is shown in the day view.booleanReturns whether strict date validation is enabled, rejecting impossible dates such as"Nov 31".booleanReturns whether the week-of-year column is shown in the calendar panels.org.zkoss.zk.ui.WrongValueExceptiononWrongValue(org.zkoss.zk.ui.WrongValueException ex) protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) voidservice(org.zkoss.zk.au.AuRequest request, boolean everError) voidsetAllowEmpty(String which) Sets which endpoints may be left empty and pushes it to the client viasmartUpdate.voidSets the placeholder shown in the begin input when empty and pushes it viasmartUpdate.voidSets the begin endpoint.voidSets the begin endpoint from aLocalDate, taken at start of day in the component's time zone.voidSets the begin endpoint from aLocalDateTime, interpreted in the component's time zone.voidSets the begin endpoint from aZonedDateTime(its instant is used).voidsetButtonVisible(boolean b) Sets whether the calendar drop-down button is shown and pushes it viasmartUpdate.voidsetConstraint(String constr) Sets the constraint from aSimpleDateConstraintexpression (e.g.voidsetConstraint(org.zkoss.zul.Constraint constr) Sets the activeConstraintinstance applied to both endpoints.voidsetDisabled(boolean b) Sets whether the component is disabled and pushes it viasmartUpdate.voidSets the placeholder shown in the end input when empty and pushes it viasmartUpdate.voidsetEndValue(Date d) Sets the end endpoint.voidSets the end endpoint from aLocalDate, taken at start of day in the component's time zone.voidSets the end endpoint from aLocalDateTime, interpreted in the component's time zone.voidSets the end endpoint from aZonedDateTime(its instant is used).voidsetErrorMessage(String errmsg) Associates an error message to this component.voidSets the date format pattern applied to both input fields, usingjava.text.SimpleDateFormatletters (e.g.voidsetHoverPreview(boolean b) Sets whether hovering a candidate end date previews the range in the calendar and pushes it viasmartUpdate.voidsetInputAttributes(String inputAttributes) Sets some additional attributes to both range input html tags in the component.voidsetInputAttributes(Map<String, String> inputAttributes) Sets some additional attributes to both range input html tags in the component.voidsetLenient(boolean b) Sets whether date parsing is lenient and pushes it viasmartUpdate.voidSets the locale from its string code (e.g.voidSets the locale used for month/weekday labels and the first-day-of-week.voidsetMaxNights(int n) Sets the maximum number of nights (difference in calendar days) allowed between begin and end and pushes it viasmartUpdate.voidsetMinNights(int n) Sets the minimum number of nights (difference in calendar days) required between begin and end and pushes it viasmartUpdate.voidsetNumberOfMonths(int n) Sets the number of side-by-side calendar panels shown in the popup and pushes it to the client viasmartUpdate.voidsetOpen(boolean open) Opens or closes the calendar popup by dispatching anAuInvoketo the client widget.voidSets the placeholder shown in both inputs when empty and pushes it viasmartUpdate.voidsetPosition(String pos) Sets where the calendar popup is anchored relative to the input box.voidsetReadonly(boolean b) Sets whether the component is read-only and pushes it viasmartUpdate.voidSets the separator string rendered between the two date inputs.voidsetShowTime(boolean b) Sets whether the popup shows a time picker and the inputs display the time component.voidsetShowTodayLink(boolean b) Sets whether the "Today" shortcut link is shown in the day view and pushes it viasmartUpdate.voidsetStrictDate(boolean b) Sets whether strict date validation is enabled and pushes it viasmartUpdate.voidsetTimeZone(String tzId) Sets the time zone from its ID (e.g.voidsetTimeZone(TimeZone tz) Sets the time zone used for calendar-day boundary decisions and forSimpleDateConstraintbound parsing.voidsetTodayLinkLabel(String todayLinkLabel) Sets the label of the "Today" shortcut shown in the popup footer (gated bysetShowTodayLink(boolean)) and pushes it viasmartUpdate.voidsetValue(org.zkoss.zul.DateRange range) Sets the range.voidsetValueInLocalDate(org.zkoss.zul.LocalDateRange r) Sets the range from aLocalDateRange, each end taken at start of day in the component's time zone.voidsetValueInLocalDateTime(org.zkoss.zul.LocalDateTimeRange r) Sets the range from aLocalDateTimeRange, each end interpreted in the component's time zone.voidsetValueInZonedDateTime(org.zkoss.zul.ZonedDateTimeRange r) Sets the range from aZonedDateTimeRange(each end's instant is used).booleansetVisible(boolean visible) voidsetWeekOfYear(boolean b) Sets whether the week-of-year column is shown in the calendar panels and pushes it viasmartUpdate.Methods inherited from class org.zkoss.zul.impl.XulElement
clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, 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, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, 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, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Constructor Details
-
Daterangebox
public Daterangebox()Constructs an empty date range picker. Both ends startnullandnumberOfMonthsis resolved lazily from the library default (seegetNumberOfMonths()) the first time it is read.- Since:
- 11.0.0
-
Daterangebox
public Daterangebox(org.zkoss.zul.DateRange range) Constructs a date range picker with the given initial range.- Parameters:
range- the initial begin/end range;nullleaves both ends empty.- Throws:
org.zkoss.zk.ui.WrongValueException- if the range violates the active constraint, the allowEmpty rule, the begin-after-end rule or the minNights/maxNights bounds.- Since:
- 11.0.0
-
-
Method Details
-
getValue
public org.zkoss.zul.DateRange getValue()Returns the current range as aDateRange. Always non-null; either or both ends may benull.- Since:
- 11.0.0
-
setValue
public void setValue(org.zkoss.zul.DateRange range) Sets the range.nullclears both ends.If an error message is pending (
getErrorMessage()), the range is validated and sent to the client even when it equals the current one, and the error message is cleared.- Parameters:
range- may benull- Throws:
org.zkoss.zk.ui.WrongValueException- if the new range violates the active constraint, the allowEmpty rule, the begin-after-end rule or the minNights/maxNights bounds.- Since:
- 11.0.0
-
getBeginValue
Returns a defensive copy of the begin endpoint, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setBeginValue
Sets the begin endpoint. In date-only mode (isShowTime()isfalse) the time-of-day component is ignored when checking the range order, so a same-calendar-day pair whose begin time is later than the end time (e.g.Jan 1 23:00/Jan 1 09:00) is accepted as a zero-night stay rather than rejected as inverted. Note thatDateRange.getDays()compares wall-clock instants, so it can still report a negative count for such a pair — validation andgetDays()intentionally use different granularities.- Parameters:
d- the new begin date;nullclears the begin endpoint.- Throws:
org.zkoss.zk.ui.WrongValueException- if the resulting range violates the active constraint, the allowEmpty rule, the begin-after-end rule or the minNights/maxNights bounds.- Since:
- 11.0.0
-
getEndValue
Returns a defensive copy of the end endpoint, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setEndValue
Sets the end endpoint. SeesetBeginValue(Date)for the date-only range-order semantics and how they relate toDateRange.getDays().- Parameters:
d- the new end date;nullclears the end endpoint.- Throws:
org.zkoss.zk.ui.WrongValueException- if the resulting range violates the active constraint, the allowEmpty rule, the begin-after-end rule or the minNights/maxNights bounds.- Since:
- 11.0.0
-
getErrorMessage
Returns the error message that is caused when user entered invalid value, or null if no error at all.- Since:
- 11.0.0
-
setErrorMessage
Associates an error message to this component. It will cause the given error message to be shown at the client.Notice that the application rarely invokes this method. Rather, throw
WrongValueExceptioninstead.- Parameters:
errmsg- the error message; null or empty clears it.- Since:
- 11.0.0
-
clearErrorMessage
public void clearErrorMessage()Clears the error message.The error message is cleared automatically, so you rarely need to call this method. However, if the error can be corrected by changing only one end with
setBeginValue(Date)orsetEndValue(Date), you may have to clear the error message manually by invoking this method, since this component cannot tell whether the end left alone is still in error.setValue(DateRange)sets both ends and clears it.- Since:
- 11.0.0
-
getBeginValueInLocalDate
Returns the begin endpoint as aLocalDatein the component's time zone, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setBeginValueInLocalDate
Sets the begin endpoint from aLocalDate, taken at start of day in the component's time zone. Equivalent tosetBeginValue(Date).- Parameters:
d- the new begin date;nullclears the begin endpoint.- Since:
- 11.0.0
-
getEndValueInLocalDate
Returns the end endpoint as aLocalDatein the component's time zone, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setEndValueInLocalDate
Sets the end endpoint from aLocalDate, taken at start of day in the component's time zone. Equivalent tosetEndValue(Date).- Parameters:
d- the new end date;nullclears the end endpoint.- Since:
- 11.0.0
-
getValueInLocalDate
public org.zkoss.zul.LocalDateRange getValueInLocalDate()Returns the range as aLocalDateRangein the component's time zone.- Since:
- 11.0.0
- See Also:
-
setValueInLocalDate
public void setValueInLocalDate(org.zkoss.zul.LocalDateRange r) Sets the range from aLocalDateRange, each end taken at start of day in the component's time zone. Equivalent tosetValue(DateRange).- Parameters:
r- the new range;nullclears both ends.- Since:
- 11.0.0
-
getBeginValueInLocalDateTime
Returns the begin endpoint as aLocalDateTimein the component's time zone, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setBeginValueInLocalDateTime
Sets the begin endpoint from aLocalDateTime, interpreted in the component's time zone. Equivalent tosetBeginValue(Date).- Parameters:
d- the new begin date-time;nullclears the begin endpoint.- Since:
- 11.0.0
-
getEndValueInLocalDateTime
Returns the end endpoint as aLocalDateTimein the component's time zone, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setEndValueInLocalDateTime
Sets the end endpoint from aLocalDateTime, interpreted in the component's time zone. Equivalent tosetEndValue(Date).- Parameters:
d- the new end date-time;nullclears the end endpoint.- Since:
- 11.0.0
-
getValueInLocalDateTime
public org.zkoss.zul.LocalDateTimeRange getValueInLocalDateTime()Returns the range as aLocalDateTimeRangein the component's time zone.- Since:
- 11.0.0
- See Also:
-
setValueInLocalDateTime
public void setValueInLocalDateTime(org.zkoss.zul.LocalDateTimeRange r) Sets the range from aLocalDateTimeRange, each end interpreted in the component's time zone. Equivalent tosetValue(DateRange).- Parameters:
r- the new range;nullclears both ends.- Since:
- 11.0.0
-
getBeginValueInZonedDateTime
Returns the begin endpoint as aZonedDateTimein the component's time zone, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setBeginValueInZonedDateTime
Sets the begin endpoint from aZonedDateTime(its instant is used). Equivalent tosetBeginValue(Date).- Parameters:
d- the new begin date-time;nullclears the begin endpoint.- Since:
- 11.0.0
-
getEndValueInZonedDateTime
Returns the end endpoint as aZonedDateTimein the component's time zone, ornullif unset.- Since:
- 11.0.0
- See Also:
-
setEndValueInZonedDateTime
Sets the end endpoint from aZonedDateTime(its instant is used). Equivalent tosetEndValue(Date).- Parameters:
d- the new end date-time;nullclears the end endpoint.- Since:
- 11.0.0
-
getValueInZonedDateTime
public org.zkoss.zul.ZonedDateTimeRange getValueInZonedDateTime()Returns the range as aZonedDateTimeRangein the component's time zone.- Since:
- 11.0.0
- See Also:
-
setValueInZonedDateTime
public void setValueInZonedDateTime(org.zkoss.zul.ZonedDateTimeRange r) Sets the range from aZonedDateTimeRange(each end's instant is used). Equivalent tosetValue(DateRange).- Parameters:
r- the new range;nullclears both ends.- Since:
- 11.0.0
-
getFormat
Returns the raw date format pattern, ornullif none was set (in which casegetRealFormat()supplies the locale-derived fallback). Default:null.- Since:
- 11.0.0
- See Also:
-
setFormat
Sets the date format pattern applied to both input fields, usingjava.text.SimpleDateFormatletters (e.g.yyyy/MM/dd). Passingnullor""resets to the locale-aware MEDIUM fallback. The resolved pattern (seegetRealFormat(), which also appends" HH:mm"whenisShowTime()is on) is pushed to the client viasmartUpdate.- Parameters:
format- the format pattern, ornull/""for the default.- Since:
- 11.0.0
-
getRealFormat
Returns the format actually used. Whenformathas not been explicitly set, falls back to the locale-aware MEDIUM pattern. IfshowTimeis explicitlytrueand no explicit format has been set," HH:mm"is appended so the input field shows the time the user picks in the popup — without this, ashowTimecomponent would let the user pick a time that the date-only input never displays.- Returns:
- the effective, never-null format pattern.
- Since:
- 11.0.0
-
getLocale
Returns the locale used for month/weekday labels and the first-day-of-week, ornull(the page/current locale) if unset. Default:null.- Since:
- 11.0.0
- See Also:
-
setLocale
Sets the locale used for month/weekday labels and the first-day-of-week.Client-side date parsing and formatting via
zk.fmt.Calendaruse the localized symbols pushed for this property.- Parameters:
locale- the locale, ornullto use the current/page locale.- Since:
- 11.0.0
-
setLocale
Sets the locale from its string code (e.g."zh_TW"), delegating tosetLocale(Locale). Passingnullor""clears the locale.- Parameters:
localeCode- the locale code, ornull/""to clear.- Since:
- 11.0.0
-
getTimeZone
Returns the time zone used for calendar-day boundary decisions and constraint-bound parsing, ornull(the current time zone) if unset. Default:null.- Since:
- 11.0.0
- See Also:
-
setTimeZone
Sets the time zone used for calendar-day boundary decisions and forSimpleDateConstraintbound parsing. The popup's "Today" button, client-side typed input parsing, server-side constraint parsing, and thevalueIn*java.time getters all honor this property.Note: an already-set
AbstractSimpleDateTimeConstraintis re-anchored to the new zone in place, so an instance shared with another component follows this zone too — seesetConstraint(Constraint).- Parameters:
tz- the time zone, ornullto use the current time zone.- Since:
- 11.0.0
-
setTimeZone
Sets the time zone from its ID (e.g."Asia/Tokyo"), delegating tosetTimeZone(TimeZone). Passingnullor""clears the time zone. BecauseTimeZone.getTimeZonesilently returns GMT for an unrecognized ID, an unknown non-GMT/UTC ID (e.g. a typo) is rejected rather than silently resolving to GMT.- Parameters:
tzId- the time zone ID, ornull/""to clear.- Throws:
org.zkoss.zk.ui.WrongValueException- iftzIdis not a recognized time zone ID.- Since:
- 11.0.0
-
getConstraint
public org.zkoss.zul.Constraint getConstraint()Returns the activeConstraint, ornullif none is set. Default:null.- Specified by:
getConstraintin interfaceorg.zkoss.zul.ext.Constrainted- Since:
- 11.0.0
- See Also:
-
getConstraintString
Returns the raw constraint string of the activeConstraintif it is aSimpleConstraint, ornullotherwise, matchingInputElement.getConstraintString(). CustomConstraintimplementations have no canonical string form, so we surfacenullrather than fabricate one — callers that need to display the active constraint should fall back togetConstraint().- Returns:
- the raw constraint string, or
null. - Since:
- 11.0.0
-
setConstraint
Sets the constraint from aSimpleDateConstraintexpression (e.g."between 20240101 and 20241231","no past"), which is applied to both the begin and end values. Passingnullor""clears the constraint. The bounds are parsed in the currentgetTimeZone().- Parameters:
constr- the constraint expression, ornull/""to clear.- Since:
- 11.0.0
-
setConstraint
public void setConstraint(org.zkoss.zul.Constraint constr) Sets the activeConstraintinstance applied to both endpoints. ASimpleDateConstraintvalidates the pair as a range; any otherConstraintis invoked per endpoint. Passingnullclears the constraint.Note: an
AbstractSimpleDateTimeConstraintis re-anchored to this component'sgetTimeZone()in place, asDateTimeFormatInputElement.setConstraint(org.zkoss.zul.Constraint)does, so an instance shared with another component follows this zone too.- Specified by:
setConstraintin interfaceorg.zkoss.zul.ext.Constrainted- Parameters:
constr- the constraint, ornullto clear.- Since:
- 11.0.0
-
getNumberOfMonths
public int getNumberOfMonths()Returns the number of side-by-side calendar panels shown in the popup. When not explicitly set, resolves the library default (org.zkoss.zul.daterangebox.numberOfMonths, default 2).- Since:
- 11.0.0
- See Also:
-
setNumberOfMonths
public void setNumberOfMonths(int n) Sets the number of side-by-side calendar panels shown in the popup and pushes it to the client viasmartUpdate. The accepted range is1to the configured maximum (library propertyorg.zkoss.zul.daterangebox.numberOfMonths.max, default 12).- Parameters:
n- the panel count; must be between 1 and the configured maximum.- Throws:
org.zkoss.zk.ui.WrongValueException- ifnis outside that range.- Since:
- 11.0.0
-
getAllowEmpty
Returns which endpoints may be left empty: one of"none","begin","end"or"both". Default:"both".- Since:
- 11.0.0
- See Also:
-
setAllowEmpty
Sets which endpoints may be left empty and pushes it to the client viasmartUpdate. Accepted tokens:"none"(both required),"begin","end"and"both"(both optional). Passingnullresets to"both".- Parameters:
which- one ofnone,begin,end,both, ornullto reset toboth.- Throws:
org.zkoss.zk.ui.WrongValueException- ifwhichis not one of the accepted tokens.- Since:
- 11.0.0
-
isShowTime
public boolean isShowTime()Returns whether the time picker is shown. If never explicitly set, auto-detected fromgetRealFormat().- Since:
- 11.0.0
- See Also:
-
setShowTime
public void setShowTime(boolean b) Sets whether the popup shows a time picker and the inputs display the time component. When turned on without an explicit format," HH:mm"is appended to the effective format (seegetRealFormat()). The new state, and any re-resolved format, are pushed viasmartUpdate. Default: unset (auto-detected from the format).- Parameters:
b-trueto show the time picker.- Since:
- 11.0.0
-
getMinNights
public int getMinNights()Returns the minimum number of nights (difference in calendar days) required between begin and end.0means no minimum. Default:0.- Since:
- 11.0.0
- See Also:
-
setMinNights
public void setMinNights(int n) Sets the minimum number of nights (difference in calendar days) required between begin and end and pushes it viasmartUpdate.0disables the minimum.- Parameters:
n- the minimum nights; must be>= 0and not exceed a non-zerogetMaxNights().- Throws:
org.zkoss.zk.ui.WrongValueException- ifnis negative, or greater than a configured non-zeromaxNights.- Since:
- 11.0.0
-
getMaxNights
public int getMaxNights()Returns the maximum number of nights (difference in calendar days) allowed between begin and end.0means unbounded. Default:0.- Since:
- 11.0.0
- See Also:
-
setMaxNights
public void setMaxNights(int n) Sets the maximum number of nights (difference in calendar days) allowed between begin and end and pushes it viasmartUpdate.0leaves the range unbounded.- Parameters:
n- the maximum nights; must be>= 0and not less than a non-zerogetMinNights().- Throws:
org.zkoss.zk.ui.WrongValueException- ifnis negative, or less than a configured non-zerominNights.- Since:
- 11.0.0
-
getPosition
Returns the popup anchor position token. Default:"after_start".- Since:
- 11.0.0
- See Also:
-
setPosition
Sets where the calendar popup is anchored relative to the input box. Default:after_start(the popup drops below the box, aligned to its left edge). Accepts the same position tokens asPopup.open(org.zkoss.zk.ui.Component, String)— e.g.before_start,after_end,start_center,end_after,overlaporat_pointer. The value is pushed to the client and applied the next time the popup opens.- Parameters:
pos- the popup position token- Since:
- 11.0.0
-
isButtonVisible
public boolean isButtonVisible()Returns whether the calendar drop-down button is shown to the right of the inputs. Default:true.- Since:
- 11.0.0
- See Also:
-
setButtonVisible
public void setButtonVisible(boolean b) Sets whether the calendar drop-down button is shown and pushes it viasmartUpdate.- Parameters:
b-trueto show the button.- Since:
- 11.0.0
-
isWeekOfYear
public boolean isWeekOfYear()Returns whether the week-of-year column is shown in the calendar panels. Default:false.- Since:
- 11.0.0
- See Also:
-
setWeekOfYear
public void setWeekOfYear(boolean b) Sets whether the week-of-year column is shown in the calendar panels and pushes it viasmartUpdate.- Parameters:
b-trueto show the week-of-year column.- Since:
- 11.0.0
-
isShowTodayLink
public boolean isShowTodayLink()Returns whether the "Today" shortcut link is shown in the day view. Default:false.- Since:
- 11.0.0
- See Also:
-
setShowTodayLink
public void setShowTodayLink(boolean b) Sets whether the "Today" shortcut link is shown in the day view and pushes it viasmartUpdate.- Parameters:
b-trueto show the "Today" link.- Since:
- 11.0.0
-
getTodayLinkLabel
Returns the label of the "Today" shortcut shown in the popup footer whenisShowTodayLink()is on.Default: the localized
MZul.CALENDAR_TODAY("Today" in English).- Since:
- 11.0.0
- See Also:
-
setTodayLinkLabel
Sets the label of the "Today" shortcut shown in the popup footer (gated bysetShowTodayLink(boolean)) and pushes it viasmartUpdate. MirrorsDatebox.setTodayLinkLabel(String)so the label is owned per-component rather than read from a global locale bundle.- Parameters:
todayLinkLabel- the label;nullis accepted and shipped as-is.- Since:
- 11.0.0
-
getInputAttributes
Returns the additional attributes which is set bysetInputAttributes(Map<String, String> inputAttributes).The attributes are rendered on both range input html tags of this component.
- Returns:
- inputAttributes a Map with attribute names as the keys, or null if not set.
- Since:
- 11.0.0
-
setInputAttributes
Sets some additional attributes to both range input html tags in the component. This will only reset the additional attributes that are set by this method.It is also how to specify the HTML
autocompleteattribute required by WCAG 1.3.5 (Identify Input Purpose) when this component collects information about the user, for exampleautocomplete=bday.- Parameters:
inputAttributes- a Map with attribute names as the keys.- Since:
- 11.0.0
-
setInputAttributes
Sets some additional attributes to both range input html tags in the component. This will only reset the additional attributes that are set by this method.- Parameters:
inputAttributes- a String of attributes separated by ";" and follow name=value rule. for example: "autocomplete=bday"- Since:
- 11.0.0
-
isOpen
public boolean isOpen()Returns whether the calendar popup is currently open. Default:false.- Since:
- 11.0.0
- See Also:
-
setOpen
public void setOpen(boolean open) Opens or closes the calendar popup by dispatching anAuInvoketo the client widget. Only works while visible, asCombobox.setOpen(boolean): the request is ignored while the component is invisible, and an open is ignored while disabled.- Parameters:
open-trueto open the popup,falseto close it.- Since:
- 11.0.0
-
setVisible
public boolean setVisible(boolean visible) - Specified by:
setVisiblein interfaceorg.zkoss.zk.ui.Component- Overrides:
setVisiblein classorg.zkoss.zk.ui.AbstractComponent
-
isLenient
public boolean isLenient()Returns whether date parsing is lenient. With lenient parsing, inputs that do not exactly match the format may be interpreted heuristically. Default:true.- Since:
- 11.0.0
- See Also:
-
setLenient
public void setLenient(boolean b) Sets whether date parsing is lenient and pushes it viasmartUpdate. With strict parsing (false), inputs must match the format exactly.- Parameters:
b-truefor lenient parsing.- Since:
- 11.0.0
-
isStrictDate
public boolean isStrictDate()Returns whether strict date validation is enabled, rejecting impossible dates such as"Nov 31". Default:false.- Since:
- 11.0.0
- See Also:
-
setStrictDate
public void setStrictDate(boolean b) Sets whether strict date validation is enabled and pushes it viasmartUpdate. Whentrue, impossible dates like"Jan 0"or"Nov 31"are refused.- Parameters:
b-trueto enable strict date validation.- Since:
- 11.0.0
-
getSeparator
Returns the explicit separator if set, otherwise the library-property default (or"~"as the final fallback).- Returns:
- the resolved separator string; never
null. - Since:
- 11.0.0
-
setSeparator
Sets the separator string rendered between the two date inputs.Reset semantics: passing
nullclears the explicit value and the next render falls back togetSeparator()'s default chain (library property "org.zkoss.zul.daterangebox.separator" →"~"). The smartUpdate pushes the resolved default so the client immediately mirrors the reset rather than carrying the previous string forward. Unique to this setter — the other String setters preserve the raw value on the wire because they have no library-property fallback.- Parameters:
s- the separator string, ornullto reset to the default.- Since:
- 11.0.0
-
getPlaceholder
Returns the placeholder applied to both inputs when no per-input placeholder is set, ornullif none. Default:null.- Since:
- 11.0.0
- See Also:
-
setPlaceholder
Sets the placeholder shown in both inputs when empty and pushes it viasmartUpdate.- Parameters:
s- the placeholder text, ornullto clear.- Since:
- 11.0.0
-
getBeginPlaceholder
Returns the placeholder for the begin input, ornullif none. Default:null.- Since:
- 11.0.0
- See Also:
-
setBeginPlaceholder
Sets the placeholder shown in the begin input when empty and pushes it viasmartUpdate.- Parameters:
s- the placeholder text, ornullto clear.- Since:
- 11.0.0
-
getEndPlaceholder
Returns the placeholder for the end input, ornullif none. Default:null.- Since:
- 11.0.0
- See Also:
-
setEndPlaceholder
Sets the placeholder shown in the end input when empty and pushes it viasmartUpdate.- Parameters:
s- the placeholder text, ornullto clear.- Since:
- 11.0.0
-
isHoverPreview
public boolean isHoverPreview()Returns whether hovering a candidate end date previews the range in the calendar. When not explicitly set, resolves the library default (org.zkoss.zul.daterangebox.hoverPreview, defaulttrue).- Since:
- 11.0.0
- See Also:
-
setHoverPreview
public void setHoverPreview(boolean b) Sets whether hovering a candidate end date previews the range in the calendar and pushes it viasmartUpdate.- Parameters:
b-trueto enable the hover preview.- Since:
- 11.0.0
-
isDisabled
public boolean isDisabled()Returns whether the component is disabled (no user interaction). Default:false.- Specified by:
isDisabledin interfaceorg.zkoss.zk.ui.ext.Disable- Since:
- 11.0.0
- See Also:
-
setDisabled
public void setDisabled(boolean b) Sets whether the component is disabled and pushes it viasmartUpdate. A disabled component ignores open requests.- Specified by:
setDisabledin interfaceorg.zkoss.zk.ui.ext.Disable- Parameters:
b-trueto disable the component.- Since:
- 11.0.0
-
isReadonly
public boolean isReadonly()Returns whether the component is read-only (value shown but not editable). Default:false.- Specified by:
isReadonlyin interfaceorg.zkoss.zk.ui.ext.Readonly- Since:
- 11.0.0
- See Also:
-
setReadonly
public void setReadonly(boolean b) Sets whether the component is read-only and pushes it viasmartUpdate. Read-only blocks typing only: the popup still opens and a pick still commits, the same contract asComboboxandDatebox.- Specified by:
setReadonlyin interfaceorg.zkoss.zk.ui.ext.Readonly- Parameters:
b-trueto make the component read-only.- Since:
- 11.0.0
-
service
public void service(org.zkoss.zk.au.AuRequest request, boolean everError) - Specified by:
servicein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
servicein classorg.zkoss.zk.ui.HtmlBasedComponent
-
onWrongValue
public org.zkoss.zk.ui.WrongValueException onWrongValue(org.zkoss.zk.ui.WrongValueException ex) - Specified by:
onWrongValuein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onWrongValuein classorg.zkoss.zk.ui.AbstractComponent
-
getExtraCtrl
- Specified by:
getExtraCtrlin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
getExtraCtrlin classorg.zkoss.zk.ui.HtmlBasedComponent
-
renderProperties
- Overrides:
renderPropertiesin classorg.zkoss.zul.impl.XulElement- Throws:
IOException
-
getZclass
- Overrides:
getZclassin classorg.zkoss.zk.ui.HtmlBasedComponent
-
beforeChildAdded
public void beforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild) Rejects ZUL child nodes. The two input fields, the calendar panels and the Timeboxes inside the popup are owned by Daterangebox / DaterangePopup and constructed dynamically — letting the application drop arbitrary children into the component would either be ignored at render time or collide with the internally-managed sub-tree.- Specified by:
beforeChildAddedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
beforeChildAddedin classorg.zkoss.zk.ui.AbstractComponent
-