Class 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.Constrainted
    A 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 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:
    10.4.0
    Author:
    peaker
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Daterangebox.RangeChangeEvent
      Event fired when the begin or end value changes (carried by onChange and onChanging).
      • Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrl
      • 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

        _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

        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

      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
      void beforeChildAdded​(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)
      Rejects ZUL child nodes.
      java.lang.String getAllowEmpty()
      Returns which endpoints may be left empty: one of "none", "begin", "end" or "both".
      java.lang.String getAutocomplete()
      Returns the HTML autocomplete token applied to both range inputs.
      java.lang.String getBeginPlaceholder()
      Returns the placeholder for the begin input, or null if none.
      java.util.Date getBeginValue()
      Returns a defensive copy of the begin endpoint, or null if unset.
      java.time.LocalDate getBeginValueInLocalDate()
      Returns the begin endpoint as a LocalDate in the component's time zone, or null if unset.
      java.time.LocalDateTime getBeginValueInLocalDateTime()
      Returns the begin endpoint as a LocalDateTime in the component's time zone, or null if unset.
      java.time.ZonedDateTime getBeginValueInZonedDateTime()
      Returns the begin endpoint as a ZonedDateTime in the component's time zone, or null if unset.
      org.zkoss.zul.Constraint getConstraint()
      Returns the active Constraint, or null if none is set.
      java.lang.String getConstraintText()
      Returns the raw constraint string set via setConstraint(String), or null if the constraint was set via setConstraint(Constraint) with anything other than a plain SimpleDateConstraint (exact class — subclasses are excluded, since their bounds can't be round-tripped through a string).
      java.lang.String getEndPlaceholder()
      Returns the placeholder for the end input, or null if none.
      java.util.Date getEndValue()
      Returns a defensive copy of the end endpoint, or null if unset.
      java.time.LocalDate getEndValueInLocalDate()
      Returns the end endpoint as a LocalDate in the component's time zone, or null if unset.
      java.time.LocalDateTime getEndValueInLocalDateTime()
      Returns the end endpoint as a LocalDateTime in the component's time zone, or null if unset.
      java.time.ZonedDateTime getEndValueInZonedDateTime()
      Returns the end endpoint as a ZonedDateTime in the component's time zone, or null if unset.
      java.lang.String getFormat()
      Returns the raw date format pattern, or null if none was set (in which case getRealFormat() supplies the locale-derived fallback).
      java.util.Locale getLocale()
      Returns the locale used for month/weekday labels and the first-day-of-week, or null (the page/current locale) if unset.
      int getMaxNights()
      Returns the maximum number of nights (difference in calendar days) allowed between begin and end.
      int getMinNights()
      Returns the minimum number of nights (difference in calendar days) required between begin and end.
      int getNumberOfMonths()
      Returns the number of side-by-side calendar panels shown in the popup.
      java.lang.String getPlaceholder()
      Returns the placeholder applied to both inputs when no per-input placeholder is set, or null if none.
      java.lang.String getPosition()
      Returns the popup anchor position token.
      java.lang.String getRealFormat()
      Returns the format actually used.
      java.lang.String getSeparator()
      Returns the explicit separator if set, otherwise the library-property default (or "~" as the final fallback).
      java.util.TimeZone getTimeZone()
      Returns the time zone used for calendar-day boundary decisions and constraint-bound parsing, or null (the current time zone) if unset.
      java.lang.String getTodayLinkLabel()
      Returns the label of the "Today" shortcut shown in the popup footer when isShowTodayLink() is on.
      org.zkoss.zul.DateRange getValue()
      Returns the current range as a DateRange.
      org.zkoss.zul.LocalDateRange getValueInLocalDate()
      Returns the range as a LocalDateRange in the component's time zone.
      org.zkoss.zul.LocalDateTimeRange getValueInLocalDateTime()
      Returns the range as a LocalDateTimeRange in the component's time zone.
      org.zkoss.zul.ZonedDateTimeRange getValueInZonedDateTime()
      Returns the range as a ZonedDateTimeRange in the component's time zone.
      java.lang.String getZclass()  
      boolean isButtonVisible()
      Returns whether the calendar drop-down button is shown to the right of the inputs.
      boolean isDisabled()
      Returns whether the component is disabled (no user interaction).
      boolean isHoverPreview()
      Returns whether hovering a candidate end date previews the range in the calendar.
      boolean isLenient()
      Returns whether date parsing is lenient.
      boolean isOpen()
      Returns whether the calendar popup is currently open.
      boolean isReadonly()
      Returns whether the component is read-only (value shown but not editable).
      boolean isShowTime()
      Returns whether the time picker is shown.
      boolean isShowTodayLink()
      Returns whether the "Today" shortcut link is shown in the day view.
      boolean isStrictDate()
      Returns whether strict date validation is enabled, rejecting impossible dates such as "Nov 31".
      boolean isWeekOfYear()
      Returns whether the week-of-year column is shown in the calendar panels.
      protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)  
      void service​(org.zkoss.zk.au.AuRequest request, boolean everError)  
      void setAllowEmpty​(java.lang.String which)
      Sets which endpoints may be left empty and pushes it to the client via smartUpdate.
      void setAutocomplete​(java.lang.String autocomplete)
      Sets the HTML autocomplete token applied to both range inputs.
      void setBeginPlaceholder​(java.lang.String s)
      Sets the placeholder shown in the begin input when empty and pushes it via smartUpdate.
      void setBeginValue​(java.util.Date d)
      Sets the begin endpoint.
      void setBeginValueInLocalDate​(java.time.LocalDate d)
      Sets the begin endpoint from a LocalDate, taken at start of day in the component's time zone.
      void setBeginValueInLocalDateTime​(java.time.LocalDateTime d)
      Sets the begin endpoint from a LocalDateTime, interpreted in the component's time zone.
      void setBeginValueInZonedDateTime​(java.time.ZonedDateTime d)
      Sets the begin endpoint from a ZonedDateTime (its instant is used).
      void setButtonVisible​(boolean b)
      Sets whether the calendar drop-down button is shown and pushes it via smartUpdate.
      void setConstraint​(java.lang.String constr)
      Sets the constraint from a SimpleDateConstraint expression (e.g.
      void setConstraint​(org.zkoss.zul.Constraint constr)
      Sets the active Constraint instance applied to both endpoints.
      void setDisabled​(boolean b)
      Sets whether the component is disabled and pushes it via smartUpdate.
      void setEndPlaceholder​(java.lang.String s)
      Sets the placeholder shown in the end input when empty and pushes it via smartUpdate.
      void setEndValue​(java.util.Date d)
      Sets the end endpoint.
      void setEndValueInLocalDate​(java.time.LocalDate d)
      Sets the end endpoint from a LocalDate, taken at start of day in the component's time zone.
      void setEndValueInLocalDateTime​(java.time.LocalDateTime d)
      Sets the end endpoint from a LocalDateTime, interpreted in the component's time zone.
      void setEndValueInZonedDateTime​(java.time.ZonedDateTime d)
      Sets the end endpoint from a ZonedDateTime (its instant is used).
      void setFormat​(java.lang.String format)
      Sets the date format pattern applied to both input fields, using java.text.SimpleDateFormat letters (e.g.
      void setHoverPreview​(boolean b)
      Sets whether hovering a candidate end date previews the range in the calendar and pushes it via smartUpdate.
      void setLenient​(boolean b)
      Sets whether date parsing is lenient and pushes it via smartUpdate.
      void setLocale​(java.lang.String localeCode)
      Sets the locale from its string code (e.g.
      void setLocale​(java.util.Locale locale)
      Sets the locale used for month/weekday labels and the first-day-of-week.
      void setMaxNights​(int n)
      Sets the maximum number of nights (difference in calendar days) allowed between begin and end and pushes it via smartUpdate.
      void setMinNights​(int n)
      Sets the minimum number of nights (difference in calendar days) required between begin and end and pushes it via smartUpdate.
      void setNumberOfMonths​(int n)
      Sets the number of side-by-side calendar panels shown in the popup and pushes it to the client via smartUpdate.
      void setOpen​(boolean open)
      Opens or closes the calendar popup by dispatching an AuInvoke to the client widget.
      void setPlaceholder​(java.lang.String s)
      Sets the placeholder shown in both inputs when empty and pushes it via smartUpdate.
      void setPosition​(java.lang.String pos)
      Sets where the calendar popup is anchored relative to the input box.
      void setReadonly​(boolean b)
      Sets whether the component is read-only and pushes it via smartUpdate.
      void setSeparator​(java.lang.String s)
      Sets the separator string rendered between the two date inputs.
      void setShowTime​(boolean b)
      Sets whether the popup shows a time picker and the inputs display the time component.
      void setShowTodayLink​(boolean b)
      Sets whether the "Today" shortcut link is shown in the day view and pushes it via smartUpdate.
      void setStrictDate​(boolean b)
      Sets whether strict date validation is enabled and pushes it via smartUpdate.
      void setTimeZone​(java.lang.String tzId)
      Sets the time zone from its ID (e.g.
      void setTimeZone​(java.util.TimeZone tz)
      Sets the time zone used for calendar-day boundary decisions and for SimpleDateConstraint bound parsing.
      void setTodayLinkLabel​(java.lang.String todayLinkLabel)
      Sets the label of the "Today" shortcut shown in the popup footer (gated by setShowTodayLink(boolean)) and pushes it via smartUpdate.
      void setValue​(org.zkoss.zul.DateRange range)
      Sets the range.
      void setValueInLocalDate​(org.zkoss.zul.LocalDateRange r)
      Sets the range from a LocalDateRange, each end taken at start of day in the component's time zone.
      void setValueInLocalDateTime​(org.zkoss.zul.LocalDateTimeRange r)
      Sets the range from a LocalDateTimeRange, each end interpreted in the component's time zone.
      void setValueInZonedDateTime​(org.zkoss.zul.ZonedDateTimeRange r)
      Sets the range from a ZonedDateTimeRange (each end's instant is used).
      void setWeekOfYear​(boolean b)
      Sets whether the week-of-year column is shown in the calendar panels and pushes it via smartUpdate.
      • 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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Daterangebox

        public Daterangebox()
        Constructs an empty date range picker. Both ends start null and numberOfMonths is resolved lazily from the library default (see getNumberOfMonths()) 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; null leaves 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 a DateRange. Always non-null; either or both ends may be null.
        Since:
        10.4.0
      • setValue

        public void setValue​(org.zkoss.zul.DateRange range)
        Sets the range. null clears both ends.
        Parameters:
        range - may be null
        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, or null if 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() is false) 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 that DateRange.getDays() compares wall-clock instants, so it can still report a negative count for such a pair — validation and getDays() intentionally use different granularities.
        Parameters:
        d - the new begin date; null clears 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, or null if unset.
        Since:
        10.4.0
        See Also:
        setEndValue(Date)
      • setEndValue

        public void setEndValue​(java.util.Date d)
        Sets the end endpoint. See setBeginValue(Date) for the date-only range-order semantics and how they relate to DateRange.getDays().
        Parameters:
        d - the new end date; null clears 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 a LocalDate in the component's time zone, or null if unset.
        Since:
        10.4.0
        See Also:
        getBeginValue()
      • setBeginValueInLocalDate

        public void setBeginValueInLocalDate​(java.time.LocalDate d)
        Sets the begin endpoint from a LocalDate, taken at start of day in the component's time zone. Equivalent to setBeginValue(Date).
        Parameters:
        d - the new begin date; null clears the begin endpoint.
        Since:
        10.4.0
      • getEndValueInLocalDate

        public java.time.LocalDate getEndValueInLocalDate()
        Returns the end endpoint as a LocalDate in the component's time zone, or null if unset.
        Since:
        10.4.0
        See Also:
        getEndValue()
      • setEndValueInLocalDate

        public void setEndValueInLocalDate​(java.time.LocalDate d)
        Sets the end endpoint from a LocalDate, taken at start of day in the component's time zone. Equivalent to setEndValue(Date).
        Parameters:
        d - the new end date; null clears the end endpoint.
        Since:
        10.4.0
      • getValueInLocalDate

        public org.zkoss.zul.LocalDateRange getValueInLocalDate()
        Returns the range as a LocalDateRange in 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 a LocalDateRange, each end taken at start of day in the component's time zone. Equivalent to setValue(DateRange).
        Parameters:
        r - the new range; null clears both ends.
        Since:
        10.4.0
      • getBeginValueInLocalDateTime

        public java.time.LocalDateTime getBeginValueInLocalDateTime()
        Returns the begin endpoint as a LocalDateTime in the component's time zone, or null if unset.
        Since:
        10.4.0
        See Also:
        getBeginValue()
      • setBeginValueInLocalDateTime

        public void setBeginValueInLocalDateTime​(java.time.LocalDateTime d)
        Sets the begin endpoint from a LocalDateTime, interpreted in the component's time zone. Equivalent to setBeginValue(Date).
        Parameters:
        d - the new begin date-time; null clears the begin endpoint.
        Since:
        10.4.0
      • getEndValueInLocalDateTime

        public java.time.LocalDateTime getEndValueInLocalDateTime()
        Returns the end endpoint as a LocalDateTime in the component's time zone, or null if unset.
        Since:
        10.4.0
        See Also:
        getEndValue()
      • setEndValueInLocalDateTime

        public void setEndValueInLocalDateTime​(java.time.LocalDateTime d)
        Sets the end endpoint from a LocalDateTime, interpreted in the component's time zone. Equivalent to setEndValue(Date).
        Parameters:
        d - the new end date-time; null clears the end endpoint.
        Since:
        10.4.0
      • getValueInLocalDateTime

        public org.zkoss.zul.LocalDateTimeRange getValueInLocalDateTime()
        Returns the range as a LocalDateTimeRange in 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 a LocalDateTimeRange, each end interpreted in the component's time zone. Equivalent to setValue(DateRange).
        Parameters:
        r - the new range; null clears both ends.
        Since:
        10.4.0
      • getBeginValueInZonedDateTime

        public java.time.ZonedDateTime getBeginValueInZonedDateTime()
        Returns the begin endpoint as a ZonedDateTime in the component's time zone, or null if unset.
        Since:
        10.4.0
        See Also:
        getBeginValue()
      • setBeginValueInZonedDateTime

        public void setBeginValueInZonedDateTime​(java.time.ZonedDateTime d)
        Sets the begin endpoint from a ZonedDateTime (its instant is used). Equivalent to setBeginValue(Date).
        Parameters:
        d - the new begin date-time; null clears the begin endpoint.
        Since:
        10.4.0
      • getEndValueInZonedDateTime

        public java.time.ZonedDateTime getEndValueInZonedDateTime()
        Returns the end endpoint as a ZonedDateTime in the component's time zone, or null if unset.
        Since:
        10.4.0
        See Also:
        getEndValue()
      • setEndValueInZonedDateTime

        public void setEndValueInZonedDateTime​(java.time.ZonedDateTime d)
        Sets the end endpoint from a ZonedDateTime (its instant is used). Equivalent to setEndValue(Date).
        Parameters:
        d - the new end date-time; null clears the end endpoint.
        Since:
        10.4.0
      • getValueInZonedDateTime

        public org.zkoss.zul.ZonedDateTimeRange getValueInZonedDateTime()
        Returns the range as a ZonedDateTimeRange in 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 a ZonedDateTimeRange (each end's instant is used). Equivalent to setValue(DateRange).
        Parameters:
        r - the new range; null clears both ends.
        Since:
        10.4.0
      • getFormat

        public java.lang.String getFormat()
        Returns the raw date format pattern, or null if none was set (in which case getRealFormat() 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, using java.text.SimpleDateFormat letters (e.g. yyyy/MM/dd). Passing null or "" resets to the locale-aware MEDIUM fallback. The resolved pattern (see getRealFormat(), which also appends " HH:mm" when isShowTime() is on) is pushed to the client via smartUpdate.
        Parameters:
        format - the format pattern, or null/"" for the default.
        Since:
        10.4.0
      • getRealFormat

        public java.lang.String getRealFormat()
        Returns the format actually used. When format has not been explicitly set, falls back to the locale-aware MEDIUM pattern. If showTime is explicitly true and 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, a showTime component 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, or null (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.Calendar use the localized symbols pushed for this property.

        Parameters:
        locale - the locale, or null to 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 to setLocale(Locale). Passing null or "" clears the locale.
        Parameters:
        localeCode - the locale code, or null/"" 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, or null (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 for SimpleDateConstraint bound parsing. The popup's "Today" button, client-side typed input parsing, server-side constraint parsing, and the valueIn* java.time getters all honor this property.
        Parameters:
        tz - the time zone, or null to 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 to setTimeZone(TimeZone). Passing null or "" clears the time zone. Because TimeZone.getTimeZone silently 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, or null/"" to clear.
        Throws:
        org.zkoss.zk.ui.WrongValueException - if tzId is not a recognized time zone ID.
        Since:
        10.4.0
      • getConstraint

        public org.zkoss.zul.Constraint getConstraint()
        Returns the active Constraint, or null if none is set. Default: null.
        Specified by:
        getConstraint in interface org.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 via setConstraint(String), or null if the constraint was set via setConstraint(Constraint) with anything other than a plain SimpleDateConstraint (exact class — subclasses are excluded, since their bounds can't be round-tripped through a string). Custom Constraint implementations have no canonical string form, so we surface null rather than fabricate one — callers that need to display the active constraint should fall back to getConstraint().
        Returns:
        the raw constraint string, or null.
        Since:
        10.4.0
      • setConstraint

        public void setConstraint​(java.lang.String constr)
        Sets the constraint from a SimpleDateConstraint expression (e.g. "between 20240101 and 20241231", "no past"), which is applied to both the begin and end values. Passing null or "" clears the constraint. The bounds are parsed in the current getTimeZone().
        Parameters:
        constr - the constraint expression, or null/"" to clear.
        Since:
        10.4.0
      • setConstraint

        public void setConstraint​(org.zkoss.zul.Constraint constr)
        Sets the active Constraint instance applied to both endpoints. A SimpleDateConstraint validates the pair as a range; any other Constraint is invoked per endpoint. Passing null clears the constraint. getConstraintText() round-trips only a plain SimpleDateConstraint (exact class).
        Specified by:
        setConstraint in interface org.zkoss.zul.ext.Constrainted
        Parameters:
        constr - the constraint, or null to 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 via smartUpdate. The accepted range is 1 to the configured maximum (library property org.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 - if n is 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 via smartUpdate. Accepted tokens: "none" (both required), "begin", "end" and "both" (both optional). Passing null resets to "both".
        Parameters:
        which - one of none, begin, end, both, or null to reset to both.
        Throws:
        org.zkoss.zk.ui.WrongValueException - if which is 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 from getRealFormat().
        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 (see getRealFormat()). The new state, and any re-resolved format, are pushed via smartUpdate. Default: unset (auto-detected from the format).
        Parameters:
        b - true to 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. 0 means 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 via smartUpdate. 0 disables the minimum.
        Parameters:
        n - the minimum nights; must be >= 0 and not exceed a non-zero getMaxNights().
        Throws:
        org.zkoss.zk.ui.WrongValueException - if n is negative, or greater than a configured non-zero maxNights.
        Since:
        10.4.0
      • getMaxNights

        public int getMaxNights()
        Returns the maximum number of nights (difference in calendar days) allowed between begin and end. 0 means 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 via smartUpdate. 0 leaves the range unbounded.
        Parameters:
        n - the maximum nights; must be >= 0 and not less than a non-zero getMinNights().
        Throws:
        org.zkoss.zk.ui.WrongValueException - if n is negative, or less than a configured non-zero minNights.
        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 as Popup.open(org.zkoss.zk.ui.Component, String) — e.g. before_start, after_end, start_center, end_after, overlap or at_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 via smartUpdate.
        Parameters:
        b - true to 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 via smartUpdate.
        Parameters:
        b - true to 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 via smartUpdate.
        Parameters:
        b - true to 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 when isShowTodayLink() 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 by setShowTodayLink(boolean)) and pushes it via smartUpdate. Mirrors Datebox.setTodayLinkLabel(String) so the label is owned per-component rather than read from a global locale bundle.
        Parameters:
        todayLinkLabel - the label; null is accepted and shipped as-is.
        Since:
        10.4.0
      • getAutocomplete

        public java.lang.String getAutocomplete()
        Returns the HTML autocomplete token 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 HTML autocomplete token 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 an AuInvoke to 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 - true to open the popup, false to 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 via smartUpdate. With strict parsing (false), inputs must match the format exactly.
        Parameters:
        b - true for 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 via smartUpdate. When true, impossible dates like "Jan 0" or "Nov 31" are refused.
        Parameters:
        b - true to 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 null clears the explicit value and the next render falls back to getSeparator()'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, or null to 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, or null if 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 via smartUpdate.
        Parameters:
        s - the placeholder text, or null to clear.
        Since:
        10.4.0
      • getBeginPlaceholder

        public java.lang.String getBeginPlaceholder()
        Returns the placeholder for the begin input, or null if 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 via smartUpdate.
        Parameters:
        s - the placeholder text, or null to clear.
        Since:
        10.4.0
      • getEndPlaceholder

        public java.lang.String getEndPlaceholder()
        Returns the placeholder for the end input, or null if 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 via smartUpdate.
        Parameters:
        s - the placeholder text, or null to 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, default true).
        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 via smartUpdate.
        Parameters:
        b - true to 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:
        isDisabled in interface org.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 via smartUpdate. A disabled component ignores open requests.
        Specified by:
        setDisabled in interface org.zkoss.zk.ui.ext.Disable
        Parameters:
        b - true to 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:
        isReadonly in interface org.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 via smartUpdate. A read-only component ignores open requests.
        Specified by:
        setReadonly in interface org.zkoss.zk.ui.ext.Readonly
        Parameters:
        b - true to make the component read-only.
        Since:
        10.4.0
      • service

        public void service​(org.zkoss.zk.au.AuRequest request,
                            boolean everError)
        Specified by:
        service in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        service in class org.zkoss.zk.ui.HtmlBasedComponent
      • renderProperties

        protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)
                                 throws java.io.IOException
        Overrides:
        renderProperties in class org.zkoss.zul.impl.XulElement
        Throws:
        java.io.IOException
      • getZclass

        public java.lang.String getZclass()
        Overrides:
        getZclass in class org.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:
        beforeChildAdded in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        beforeChildAdded in class org.zkoss.zk.ui.AbstractComponent