Class Daterangebox
- java.lang.Object
-
- org.zkoss.zk.ui.AbstractComponent
-
- org.zkoss.zk.ui.HtmlBasedComponent
-
- org.zkoss.zul.impl.XulElement
-
- org.zkoss.zkmax.zul.Daterangebox
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.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
public class Daterangebox extends org.zkoss.zul.impl.XulElement implements org.zkoss.zk.ui.ext.Disable, org.zkoss.zk.ui.ext.Readonly, org.zkoss.zul.ext.ConstraintedA date range picker. Allows users to select a contiguous range of dates (optionally including time) via a popup with one or more side-by-side calendar panels and an optional minimum / maximum length constraint.Value is a
DateRangecomposed of a begin date and an end date. Either end may benullwhensetAllowEmpty(String)permits.Reuses
SimpleDateConstraintfor 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
onChangeandonChangingdeliver aDaterangebox.RangeChangeEvent(which extendsEvent), not anInputEvent— a two-ended range cannot be carried by the single value of anInputEvent. A server-side listener must declare its parameter asDaterangebox.RangeChangeEventand readDaterangebox.RangeChangeEvent.getRange(),Daterangebox.RangeChangeEvent.getBegin()orDaterangebox.RangeChangeEvent.getEnd(); a handler typedonChange(InputEvent), or a ZUL EL expression readingevent.value, will not match. Data binding is unaffected:@bind/@savepersist through thevalue/beginValue/endValueproperties rather than the event object.- Since:
- 10.4.0
- Author:
- peaker
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDaterangebox.RangeChangeEventEvent fired when the begin or end value changes (carried byonChangeandonChanging).
-
Constructor Summary
Constructors Constructor Description Daterangebox()Constructs an empty date range picker.Daterangebox(org.zkoss.zul.DateRange range)Constructs a date range picker with the given initial range.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)Rejects ZUL child nodes.java.lang.StringgetAllowEmpty()Returns which endpoints may be left empty: one of"none","begin","end"or"both".java.lang.StringgetAutocomplete()Returns the HTMLautocompletetoken applied to both range inputs.java.lang.StringgetBeginPlaceholder()Returns the placeholder for the begin input, ornullif none.java.util.DategetBeginValue()Returns a defensive copy of the begin endpoint, ornullif unset.java.time.LocalDategetBeginValueInLocalDate()Returns the begin endpoint as aLocalDatein the component's time zone, ornullif unset.java.time.LocalDateTimegetBeginValueInLocalDateTime()Returns the begin endpoint as aLocalDateTimein the component's time zone, ornullif unset.java.time.ZonedDateTimegetBeginValueInZonedDateTime()Returns the begin endpoint as aZonedDateTimein the component's time zone, ornullif unset.org.zkoss.zul.ConstraintgetConstraint()Returns the activeConstraint, ornullif none is set.java.lang.StringgetConstraintText()Returns the raw constraint string set viasetConstraint(String), ornullif the constraint was set viasetConstraint(Constraint)with anything other than a plainSimpleDateConstraint(exact class — subclasses are excluded, since their bounds can't be round-tripped through a string).java.lang.StringgetEndPlaceholder()Returns the placeholder for the end input, ornullif none.java.util.DategetEndValue()Returns a defensive copy of the end endpoint, ornullif unset.java.time.LocalDategetEndValueInLocalDate()Returns the end endpoint as aLocalDatein the component's time zone, ornullif unset.java.time.LocalDateTimegetEndValueInLocalDateTime()Returns the end endpoint as aLocalDateTimein the component's time zone, ornullif unset.java.time.ZonedDateTimegetEndValueInZonedDateTime()Returns the end endpoint as aZonedDateTimein the component's time zone, ornullif unset.java.lang.StringgetFormat()Returns the raw date format pattern, ornullif none was set (in which casegetRealFormat()supplies the locale-derived fallback).java.util.LocalegetLocale()Returns the locale used for month/weekday labels and the first-day-of-week, ornull(the page/current locale) if unset.intgetMaxNights()Returns the maximum number of nights (difference in calendar days) allowed between begin and end.intgetMinNights()Returns the minimum number of nights (difference in calendar days) required between begin and end.intgetNumberOfMonths()Returns the number of side-by-side calendar panels shown in the popup.java.lang.StringgetPlaceholder()Returns the placeholder applied to both inputs when no per-input placeholder is set, ornullif none.java.lang.StringgetPosition()Returns the popup anchor position token.java.lang.StringgetRealFormat()Returns the format actually used.java.lang.StringgetSeparator()Returns the explicit separator if set, otherwise the library-property default (or"~"as the final fallback).java.util.TimeZonegetTimeZone()Returns the time zone used for calendar-day boundary decisions and constraint-bound parsing, ornull(the current time zone) if unset.java.lang.StringgetTodayLinkLabel()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.LocalDateRangegetValueInLocalDate()Returns the range as aLocalDateRangein the component's time zone.org.zkoss.zul.LocalDateTimeRangegetValueInLocalDateTime()Returns the range as aLocalDateTimeRangein the component's time zone.org.zkoss.zul.ZonedDateTimeRangegetValueInZonedDateTime()Returns the range as aZonedDateTimeRangein the component's time zone.java.lang.StringgetZclass()booleanisButtonVisible()Returns whether the calendar drop-down button is shown to the right of the inputs.booleanisDisabled()Returns whether the component is disabled (no user interaction).booleanisHoverPreview()Returns whether hovering a candidate end date previews the range in the calendar.booleanisLenient()Returns whether date parsing is lenient.booleanisOpen()Returns whether the calendar popup is currently open.booleanisReadonly()Returns whether the component is read-only (value shown but not editable).booleanisShowTime()Returns whether the time picker is shown.booleanisShowTodayLink()Returns whether the "Today" shortcut link is shown in the day view.booleanisStrictDate()Returns whether strict date validation is enabled, rejecting impossible dates such as"Nov 31".booleanisWeekOfYear()Returns whether the week-of-year column is shown in the calendar panels.protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)voidservice(org.zkoss.zk.au.AuRequest request, boolean everError)voidsetAllowEmpty(java.lang.String which)Sets which endpoints may be left empty and pushes it to the client viasmartUpdate.voidsetAutocomplete(java.lang.String autocomplete)Sets the HTMLautocompletetoken applied to both range inputs.voidsetBeginPlaceholder(java.lang.String s)Sets the placeholder shown in the begin input when empty and pushes it viasmartUpdate.voidsetBeginValue(java.util.Date d)Sets the begin endpoint.voidsetBeginValueInLocalDate(java.time.LocalDate d)Sets the begin endpoint from aLocalDate, taken at start of day in the component's time zone.voidsetBeginValueInLocalDateTime(java.time.LocalDateTime d)Sets the begin endpoint from aLocalDateTime, interpreted in the component's time zone.voidsetBeginValueInZonedDateTime(java.time.ZonedDateTime d)Sets 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(java.lang.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.voidsetEndPlaceholder(java.lang.String s)Sets the placeholder shown in the end input when empty and pushes it viasmartUpdate.voidsetEndValue(java.util.Date d)Sets the end endpoint.voidsetEndValueInLocalDate(java.time.LocalDate d)Sets the end endpoint from aLocalDate, taken at start of day in the component's time zone.voidsetEndValueInLocalDateTime(java.time.LocalDateTime d)Sets the end endpoint from aLocalDateTime, interpreted in the component's time zone.voidsetEndValueInZonedDateTime(java.time.ZonedDateTime d)Sets the end endpoint from aZonedDateTime(its instant is used).voidsetFormat(java.lang.String format)Sets 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.voidsetLenient(boolean b)Sets whether date parsing is lenient and pushes it viasmartUpdate.voidsetLocale(java.lang.String localeCode)Sets the locale from its string code (e.g.voidsetLocale(java.util.Locale locale)Sets 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.voidsetPlaceholder(java.lang.String s)Sets the placeholder shown in both inputs when empty and pushes it viasmartUpdate.voidsetPosition(java.lang.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.voidsetSeparator(java.lang.String s)Sets 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(java.lang.String tzId)Sets the time zone from its ID (e.g.voidsetTimeZone(java.util.TimeZone tz)Sets the time zone used for calendar-day boundary decisions and forSimpleDateConstraintbound parsing.voidsetTodayLinkLabel(java.lang.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).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, setTooltipAttributes
-
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, 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, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
-
Methods 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, onWrongValue, 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, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
-
-
-
Constructor Detail
-
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:
- 10.4.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:
- 10.4.0
-
-
Method Detail
-
getValue
public org.zkoss.zul.DateRange getValue()
Returns the current range as aDateRange. Always non-null; either or both ends may benull.- Since:
- 10.4.0
-
setValue
public void setValue(org.zkoss.zul.DateRange range)
Sets the range.nullclears both ends.- 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:
- 10.4.0
-
getBeginValue
public java.util.Date getBeginValue()
Returns a defensive copy of the begin endpoint, ornullif unset.- Since:
- 10.4.0
- See Also:
setBeginValue(Date)
-
setBeginValue
public void setBeginValue(java.util.Date d)
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:
- 10.4.0
-
getEndValue
public java.util.Date getEndValue()
Returns a defensive copy of the end endpoint, ornullif unset.- Since:
- 10.4.0
- See Also:
setEndValue(Date)
-
setEndValue
public void setEndValue(java.util.Date d)
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:
- 10.4.0
-
getBeginValueInLocalDate
public java.time.LocalDate getBeginValueInLocalDate()
Returns the begin endpoint as aLocalDatein the component's time zone, ornullif unset.- Since:
- 10.4.0
- See Also:
getBeginValue()
-
setBeginValueInLocalDate
public void setBeginValueInLocalDate(java.time.LocalDate d)
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:
- 10.4.0
-
getEndValueInLocalDate
public java.time.LocalDate getEndValueInLocalDate()
Returns the end endpoint as aLocalDatein the component's time zone, ornullif unset.- Since:
- 10.4.0
- See Also:
getEndValue()
-
setEndValueInLocalDate
public void setEndValueInLocalDate(java.time.LocalDate d)
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:
- 10.4.0
-
getValueInLocalDate
public org.zkoss.zul.LocalDateRange getValueInLocalDate()
Returns the range as aLocalDateRangein the component's time zone.- Since:
- 10.4.0
- See Also:
getValue()
-
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:
- 10.4.0
-
getBeginValueInLocalDateTime
public java.time.LocalDateTime getBeginValueInLocalDateTime()
Returns the begin endpoint as aLocalDateTimein the component's time zone, ornullif unset.- Since:
- 10.4.0
- See Also:
getBeginValue()
-
setBeginValueInLocalDateTime
public void setBeginValueInLocalDateTime(java.time.LocalDateTime d)
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:
- 10.4.0
-
getEndValueInLocalDateTime
public java.time.LocalDateTime getEndValueInLocalDateTime()
Returns the end endpoint as aLocalDateTimein the component's time zone, ornullif unset.- Since:
- 10.4.0
- See Also:
getEndValue()
-
setEndValueInLocalDateTime
public void setEndValueInLocalDateTime(java.time.LocalDateTime d)
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:
- 10.4.0
-
getValueInLocalDateTime
public org.zkoss.zul.LocalDateTimeRange getValueInLocalDateTime()
Returns the range as aLocalDateTimeRangein the component's time zone.- Since:
- 10.4.0
- See Also:
getValue()
-
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:
- 10.4.0
-
getBeginValueInZonedDateTime
public java.time.ZonedDateTime getBeginValueInZonedDateTime()
Returns the begin endpoint as aZonedDateTimein the component's time zone, ornullif unset.- Since:
- 10.4.0
- See Also:
getBeginValue()
-
setBeginValueInZonedDateTime
public void setBeginValueInZonedDateTime(java.time.ZonedDateTime d)
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:
- 10.4.0
-
getEndValueInZonedDateTime
public java.time.ZonedDateTime getEndValueInZonedDateTime()
Returns the end endpoint as aZonedDateTimein the component's time zone, ornullif unset.- Since:
- 10.4.0
- See Also:
getEndValue()
-
setEndValueInZonedDateTime
public void setEndValueInZonedDateTime(java.time.ZonedDateTime d)
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:
- 10.4.0
-
getValueInZonedDateTime
public org.zkoss.zul.ZonedDateTimeRange getValueInZonedDateTime()
Returns the range as aZonedDateTimeRangein the component's time zone.- Since:
- 10.4.0
- See Also:
getValue()
-
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:
- 10.4.0
-
getFormat
public java.lang.String getFormat()
Returns the raw date format pattern, ornullif none was set (in which casegetRealFormat()supplies the locale-derived fallback). Default:null.- Since:
- 10.4.0
- See Also:
setFormat(String)
-
setFormat
public void setFormat(java.lang.String format)
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:
- 10.4.0
-
getRealFormat
public java.lang.String 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:
- 10.4.0
-
getLocale
public java.util.Locale 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:
- 10.4.0
- See Also:
setLocale(Locale)
-
setLocale
public void setLocale(java.util.Locale locale)
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:
- 10.4.0
-
setLocale
public void setLocale(java.lang.String localeCode)
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:
- 10.4.0
-
getTimeZone
public java.util.TimeZone 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:
- 10.4.0
- See Also:
setTimeZone(TimeZone)
-
setTimeZone
public void setTimeZone(java.util.TimeZone tz)
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.- Parameters:
tz- the time zone, ornullto use the current time zone.- Since:
- 10.4.0
-
setTimeZone
public void setTimeZone(java.lang.String tzId)
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:
- 10.4.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:
- 10.4.0
- See Also:
setConstraint(Constraint),getConstraintText()
-
getConstraintText
public java.lang.String getConstraintText()
Returns the raw constraint string set viasetConstraint(String), ornullif the constraint was set viasetConstraint(Constraint)with anything other than a plainSimpleDateConstraint(exact class — subclasses are excluded, since their bounds can't be round-tripped through a string). 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:
- 10.4.0
-
setConstraint
public void setConstraint(java.lang.String constr)
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:
- 10.4.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.getConstraintText()round-trips only a plainSimpleDateConstraint(exact class).- Specified by:
setConstraintin interfaceorg.zkoss.zul.ext.Constrainted- Parameters:
constr- the constraint, ornullto clear.- Since:
- 10.4.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:
- 10.4.0
- See Also:
setNumberOfMonths(int)
-
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:
- 10.4.0
-
getAllowEmpty
public java.lang.String getAllowEmpty()
Returns which endpoints may be left empty: one of"none","begin","end"or"both". Default:"both".- Since:
- 10.4.0
- See Also:
setAllowEmpty(String)
-
setAllowEmpty
public void setAllowEmpty(java.lang.String which)
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:
- 10.4.0
-
isShowTime
public boolean isShowTime()
Returns whether the time picker is shown. If never explicitly set, auto-detected fromgetRealFormat().- Since:
- 10.4.0
- See Also:
setShowTime(boolean)
-
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:
- 10.4.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:
- 10.4.0
- See Also:
setMinNights(int)
-
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:
- 10.4.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:
- 10.4.0
- See Also:
setMaxNights(int)
-
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:
- 10.4.0
-
getPosition
public java.lang.String getPosition()
Returns the popup anchor position token. Default:"after_start".- Since:
- 10.4.0
- See Also:
setPosition(String)
-
setPosition
public void setPosition(java.lang.String pos)
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:
- 10.4.0
-
isButtonVisible
public boolean isButtonVisible()
Returns whether the calendar drop-down button is shown to the right of the inputs. Default:true.- Since:
- 10.4.0
- See Also:
setButtonVisible(boolean)
-
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:
- 10.4.0
-
isWeekOfYear
public boolean isWeekOfYear()
Returns whether the week-of-year column is shown in the calendar panels. Default:false.- Since:
- 10.4.0
- See Also:
setWeekOfYear(boolean)
-
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:
- 10.4.0
-
isShowTodayLink
public boolean isShowTodayLink()
Returns whether the "Today" shortcut link is shown in the day view. Default:false.- Since:
- 10.4.0
- See Also:
setShowTodayLink(boolean)
-
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:
- 10.4.0
-
getTodayLinkLabel
public java.lang.String 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:
- 10.4.0
- See Also:
setTodayLinkLabel(String)
-
setTodayLinkLabel
public void setTodayLinkLabel(java.lang.String todayLinkLabel)
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:
- 10.4.0
-
getAutocomplete
public java.lang.String getAutocomplete()
Returns the HTMLautocompletetoken applied to both range inputs. Default is"off". For WCAG 1.3.5 (Identify Input Purpose), set a meaningful token such as"bday"for birth-date selection.- Since:
- 10.4.0
-
setAutocomplete
public void setAutocomplete(java.lang.String autocomplete)
Sets the HTMLautocompletetoken applied to both range inputs. Pass"off"to disable browser autofill, or a value from the HTML autofill detail token list (e.g."bday") so user agents can offer relevant fill suggestions. Required for WCAG 1.3.5 compliance when the inputs collect information about the user.- Since:
- 10.4.0
-
isOpen
public boolean isOpen()
Returns whether the calendar popup is currently open. Default:false.- Since:
- 10.4.0
- See Also:
setOpen(boolean)
-
setOpen
public void setOpen(boolean open)
Opens or closes the calendar popup by dispatching anAuInvoketo the client widget. A request to open while the component is disabled or readonly is ignored (it stays closed), mirroring the client behaviour.- Parameters:
open-trueto open the popup,falseto close it.- Since:
- 10.4.0
-
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:
- 10.4.0
- See Also:
setLenient(boolean)
-
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:
- 10.4.0
-
isStrictDate
public boolean isStrictDate()
Returns whether strict date validation is enabled, rejecting impossible dates such as"Nov 31". Default:false.- Since:
- 10.4.0
- See Also:
setStrictDate(boolean)
-
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:
- 10.4.0
-
getSeparator
public java.lang.String 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:
- 10.4.0
-
setSeparator
public void setSeparator(java.lang.String s)
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:
- 10.4.0
-
getPlaceholder
public java.lang.String getPlaceholder()
Returns the placeholder applied to both inputs when no per-input placeholder is set, ornullif none. Default:null.- Since:
- 10.4.0
- See Also:
setPlaceholder(String)
-
setPlaceholder
public void setPlaceholder(java.lang.String s)
Sets the placeholder shown in both inputs when empty and pushes it viasmartUpdate.- Parameters:
s- the placeholder text, ornullto clear.- Since:
- 10.4.0
-
getBeginPlaceholder
public java.lang.String getBeginPlaceholder()
Returns the placeholder for the begin input, ornullif none. Default:null.- Since:
- 10.4.0
- See Also:
setBeginPlaceholder(String)
-
setBeginPlaceholder
public void setBeginPlaceholder(java.lang.String s)
Sets the placeholder shown in the begin input when empty and pushes it viasmartUpdate.- Parameters:
s- the placeholder text, ornullto clear.- Since:
- 10.4.0
-
getEndPlaceholder
public java.lang.String getEndPlaceholder()
Returns the placeholder for the end input, ornullif none. Default:null.- Since:
- 10.4.0
- See Also:
setEndPlaceholder(String)
-
setEndPlaceholder
public void setEndPlaceholder(java.lang.String s)
Sets the placeholder shown in the end input when empty and pushes it viasmartUpdate.- Parameters:
s- the placeholder text, ornullto clear.- Since:
- 10.4.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:
- 10.4.0
- See Also:
setHoverPreview(boolean)
-
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:
- 10.4.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:
- 10.4.0
- See Also:
setDisabled(boolean)
-
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:
- 10.4.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:
- 10.4.0
- See Also:
setReadonly(boolean)
-
setReadonly
public void setReadonly(boolean b)
Sets whether the component is read-only and pushes it viasmartUpdate. A read-only component ignores open requests.- Specified by:
setReadonlyin interfaceorg.zkoss.zk.ui.ext.Readonly- Parameters:
b-trueto make the component read-only.- Since:
- 10.4.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
-
renderProperties
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException- Overrides:
renderPropertiesin classorg.zkoss.zul.impl.XulElement- Throws:
java.io.IOException
-
getZclass
public java.lang.String 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
-
-