Class DatePicker

  • All Implemented Interfaces:
    Serializable, org.apache.wicket.IComponentAwareEventSink, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.IComponentAwareHeaderContributor, org.apache.wicket.util.io.IClusterable, org.wicketstuff.jwicket.IStyleResolver

    public class DatePicker
    extends org.wicketstuff.jwicket.JQueryDurableAjaxBehavior
    implements org.wicketstuff.jwicket.IStyleResolver
    You can add an instance of this class to a Wicket Component to make it a resizable Component. An instance of this class can be added to one and only one Component. Another Component that should have exactly the same behavior needs it's own instance.
    See Also:
    Serialized Form
    • Field Detail

      • uiDatepickerJs

        public static final org.wicketstuff.jwicket.JQueryResourceReference uiDatepickerJs
      • uiDatepickerJs_de

        public static final org.wicketstuff.jwicket.JQueryResourceReference uiDatepickerJs_de
      • datePickerDefaultShowDayState

        public static final org.wicketstuff.jwicket.JQueryResourceReference datePickerDefaultShowDayState
      • options

        protected org.wicketstuff.jwicket.JsMap options
    • Constructor Detail

      • DatePicker

        public DatePicker()
      • DatePicker

        public DatePicker​(org.apache.wicket.request.resource.ResourceReference icon)
    • Method Detail

      • respond

        protected void respond​(org.apache.wicket.ajax.AjaxRequestTarget target)
        Handles the event processing during resizing.
        Overrides:
        respond in class org.wicketstuff.jwicket.JQueryAjaxBehavior
      • setButtonImageOnly

        public DatePicker setButtonImageOnly​(boolean value)
        Sets the 'buttonImageOnly' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setButtonImageOnly

        public DatePicker setButtonImageOnly​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                             boolean value)
      • setAutoSize

        public DatePicker setAutoSize​(boolean value)
        Sets the 'autoSize' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setAutoSize

        public DatePicker setAutoSize​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                      boolean value)
      • setButtonText

        public DatePicker setButtonText​(String value)
        Sets the 'buttonText' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - The new buttonText or null to remove this option.
        Returns:
        this object
      • setButtonText

        public DatePicker setButtonText​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                        String value)
      • setButtonImage

        public DatePicker setButtonImage​(String value)
        Sets a button image that is displayed near the TextField for the visual date representation.
      • setButtonImage

        public DatePicker setButtonImage​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                         String value)
      • setButtonImage

        public DatePicker setButtonImage​(org.apache.wicket.request.resource.ResourceReference value)
        Sets a button image that is displayed near the TextField for the visual date representation.
      • setButtonImage

        public DatePicker setButtonImage​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                         org.apache.wicket.request.resource.ResourceReference value)
      • setChangeMonth

        public DatePicker setChangeMonth​(boolean value)
        Sets the 'changeMonth' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setChangeMonth

        public DatePicker setChangeMonth​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                         boolean value)
      • setChangeYear

        public DatePicker setChangeYear​(boolean value)
        Sets the 'changeYear' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setChangeYear

        public DatePicker setChangeYear​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                        boolean value)
      • setCloseText

        public DatePicker setCloseText​(String value)
        Sets the 'closeText' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setCloseText

        public DatePicker setCloseText​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                       String value)
      • setConstraintInput

        public DatePicker setConstraintInput​(boolean value)
        Sets the 'constraintInput' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setConstraintInput

        public DatePicker setConstraintInput​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                             boolean value)
      • setCurrentText

        public DatePicker setCurrentText​(String value)
        Sets the 'currentText' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - Text to be dsiplayes on button
        Returns:
        this object
      • setCurrentText

        public DatePicker setCurrentText​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                         String value)
      • setDateFormat

        public DatePicker setDateFormat​(String value)
        Sets the 'dateFormat' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - the date format
        Returns:
        this object
      • setDateFormat

        public DatePicker setDateFormat​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                        String value)
      • setDate

        public DatePicker setDate​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                  Date date)
      • setDuration

        public DatePicker setDuration​(String value)
        Sets the 'duration' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - duration in ms
        Returns:
        this object
      • setDuration

        public DatePicker setDuration​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                      String value)
      • setDuration

        public DatePicker setDuration​(int value)
      • setDuration

        public DatePicker setDuration​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                      int value)
      • setDuration

        public DatePicker setDuration​(org.wicketstuff.jwicket.JQuerySpeed value)
        Sets the 'duration' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - duration
        Returns:
        this object
      • setDuration

        public DatePicker setDuration​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                      org.wicketstuff.jwicket.JQuerySpeed value)
      • setYearRange

        public DatePicker setYearRange​(String value)
        The range of years displayed in the year drop-down: either relative to today's year ("-nn:+nn"), relative to the currently selected year ("c-nn:c+nn"), absolute ("nnnn:nnnn"), or combinations of these formats ("nnnn:-nn"). Note that this option only affects what appears in the drop-down, to restrict which dates may be selected use the minDate and/or maxDate options.
      • setMaxDate

        public DatePicker setMaxDate​(String value)
        Sets the 'maxDate' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - max date as String
        Returns:
        this object
      • setMaxDate

        public DatePicker setMaxDate​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                     String value)
      • setMaxDate

        public DatePicker setMaxDate​(Date value)
        Sets the 'maxDate' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - max date as String
        Returns:
        this object
      • setMaxDate

        public DatePicker setMaxDate​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                     Date value)
      • setMaxDate

        public DatePicker setMaxDate​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                     Date value)
      • setMinDate

        public DatePicker setMinDate​(String value)
        Sets the 'minDate' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - min date as String
        Returns:
        this object
      • setMinDate

        public DatePicker setMinDate​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                     String value)
      • setMinDate

        public DatePicker setMinDate​(Date value)
        Sets the 'minDate' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - min date as String
        Returns:
        this object
      • setMinDate

        public DatePicker setMinDate​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                     Date value)
      • setMinDate

        public DatePicker setMinDate​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                     Date value)
      • setNumberOfMonths

        public DatePicker setNumberOfMonths​(int value)
        Sets the 'numberOfMonths' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - the number of months to show at one
        Returns:
        this object
      • setNumberOfMonths

        public DatePicker setNumberOfMonths​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                            int value)
      • setNumberOfMonths

        public DatePicker setNumberOfMonths​(int rows,
                                            int columns)
        Sets the 'numberOfMonths' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
      • setNumberOfMonths

        public DatePicker setNumberOfMonths​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                            int rows,
                                            int columns)
      • setSelectOtherMonths

        public DatePicker setSelectOtherMonths​(boolean value)
        Sets the 'selectOtherMonths' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setSelectOtherMonths

        public DatePicker setSelectOtherMonths​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                               boolean value)
      • setShowAnim

        public DatePicker setShowAnim​(DatePicker.ShowAnim value)
        Sets the 'showAnim' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setShowButtonPanel

        public DatePicker setShowButtonPanel​(boolean value)
        Sets the 'showButtonPanel' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setShowButtonPanel

        public DatePicker setShowButtonPanel​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                             boolean value)
      • setShowCurrentAtPos

        public DatePicker setShowCurrentAtPos​(int value)
        Sets the 'showCurrentAtPos' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setShowCurrentAtPos

        public DatePicker setShowCurrentAtPos​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                              int value)
      • setShowMonthAfterYear

        public DatePicker setShowMonthAfterYear​(boolean value)
        Sets the 'showMonthAfterYear' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setShowMonthAfterYear

        public DatePicker setShowMonthAfterYear​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                                boolean value)
      • getJQueryObjectOfComponent

        protected String getJQueryObjectOfComponent​(org.apache.wicket.Component component)
      • setShowOn

        public DatePicker setShowOn​(DatePicker.ShowOnTrigger value)
        Sets the 'showOn' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setShowOtherMonths

        public DatePicker setShowOtherMonths​(boolean value)
        Sets the 'showOtherMonths' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setShowOtherMonths

        public DatePicker setShowOtherMonths​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                             boolean value)
      • setShowWeek

        public DatePicker setShowWeek​(boolean value)
        Sets the 'showWeek' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - true or false.
        Returns:
        this object
      • setShowWeek

        public DatePicker setShowWeek​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                      boolean value)
      • setStepMonths

        public DatePicker setStepMonths​(int value)
        Sets the 'stepMonths' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        value - how many months to move in one step
        Returns:
        this object
      • setStepMonths

        public DatePicker setStepMonths​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                        int value)
      • setMonthNamesShort

        public DatePicker setMonthNamesShort​(String[] monthNamesShort)
        Sets the 'monthNamesShort' property for this DatePicker. Please consult the jQuery documentation for a detailed description of this property.
        Parameters:
        monthNamesShort - The list of abbreviated month names, as used in the month header on each datepicker and as requested via the dateFormat option. Ex. new String[]{ "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"}
        Returns:
        this object
      • setCssClass

        public void setCssClass​(String cssClass)
        If you want en individual style for a DatePicker you may set this style with this method. The DatePicker the gets sourrounded with a <div class="...">. Normally a DatePicker element looks like
         <div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ....>...</div>
         
        If you set a cssClass the DatePicket looks like
         <div class="cssClass"><div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ....>...</div></div>
         
        Parameters:
        cssClass - your custom css class
      • setWantOnSelectNotification

        public DatePicker setWantOnSelectNotification​(boolean value)
        If set to true, the callback-Method onSelect(AjaxRequestTarget, String, SpecialKeys) is called when a date was picked. See the jquery-ui documentation for more information
        Parameters:
        value - true or false.
        Returns:
        this object
      • setWantOnCloseNotification

        public DatePicker setWantOnCloseNotification​(boolean value)
        If set to true, the callback-Method onClose(AjaxRequestTarget, String, SpecialKeys) is called when a date was picked. See the jquery-ui documentation for more information
        Parameters:
        value - true or false.
        Returns:
        this object
      • setWantOnBeforeShowNotificationWanted

        public DatePicker setWantOnBeforeShowNotificationWanted​(boolean value)
        If set to true, the callback-Method onBeforeShow(org.apache.wicket.ajax.AjaxRequestTarget) is called before the DatePicker gets displayed.

        See the jquery-ui documentation for detailed information

        Returns:
        this object
      • updateAjaxAttributes

        protected void updateAjaxAttributes​(org.apache.wicket.ajax.attributes.AjaxRequestAttributes attributes)
        Overrides:
        updateAjaxAttributes in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
      • getJsBuilder

        protected org.wicketstuff.jwicket.JQueryAjaxBehavior.JsBuilder getJsBuilder()
        Specified by:
        getJsBuilder in class org.wicketstuff.jwicket.JQueryDurableAjaxBehavior
      • onChangeMonthJsFunction

        protected org.wicketstuff.jwicket.JQueryAjaxBehavior.JsFunction onChangeMonthJsFunction()
      • configureOnSelectGetOrPost

        protected String configureOnSelectGetOrPost()
      • hasToAddBeforeShowDayToOptions

        protected boolean hasToAddBeforeShowDayToOptions()
      • onBeforeShow

        protected void onBeforeShow​(org.apache.wicket.ajax.AjaxRequestTarget target)
      • onSelect

        protected void onSelect​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                String pickedDate,
                                org.wicketstuff.jwicket.SpecialKeys specialKeys)
        If you have set setWantOnSelectNotification(boolean) to true this method is called after the user picked a date in the datepicker.
        Parameters:
        target - the AjaxRequestTarget of the resize operation.
        pickedDate - The selected date as String
        specialKeys - the special keys that were pressed when the event occurs
      • onClose

        protected void onClose​(org.apache.wicket.ajax.AjaxRequestTarget target,
                               String pickedDate,
                               org.wicketstuff.jwicket.SpecialKeys specialKeys)
        If you have set setWantOnCloseNotification(boolean) to true this method is called after the datepicker was closed, regardless of picking a date.
        Parameters:
        target - the AjaxRequestTarget of the resize operation.
        specialKeys - the special keys that were pressed when the event occurs
      • onChangeMonthYear

        protected void onChangeMonthYear​(org.apache.wicket.ajax.AjaxRequestTarget target,
                                         String year,
                                         String month,
                                         org.wicketstuff.jwicket.SpecialKeys specialKeys)
        If you have set setWantOnChangeMonthYearNotification(boolean) to true this method is called after another moth or year is displayed, regardless of picking a date.
        Parameters:
        target - the AjaxRequestTarget of the resize operation.
        specialKeys - the special keys that were pressed when the event occurs
      • addShowDayState

        public void addShowDayState​(DatePicker.ShowDay state)
        Add one more special treatment for a day. If you don't provide a DatePicker.ShowDay object for a day it is selectable by default. Use this method if you want a special treatment (selectable, CSS class oder tooltip text) for a day. You may call this method as often as you like. The state is added to the existing list of states. Do not provide different states for one day. The resulting behavior is not defined.
        Parameters:
        state - as specific treatment for one day.
      • setShowDayStates

        public void setShowDayStates​(Collection<DatePicker.ShowDay> states)
        Set the special treatments for multiple days at one. This removes all former definitons and replaces them with the new states.
        Parameters:
        states - A Collection of states.
      • renderHead

        public void renderHead​(org.apache.wicket.Component component,
                               org.apache.wicket.markup.head.IHeaderResponse response)
        Specified by:
        renderHead in interface org.apache.wicket.markup.html.IComponentAwareHeaderContributor
        Overrides:
        renderHead in class org.wicketstuff.jwicket.JQueryDurableAjaxBehavior
      • getJsShowDatesVariable

        protected StringBuilder getJsShowDatesVariable()
      • disable

        public void disable​(org.apache.wicket.ajax.AjaxRequestTarget target)
        Disable the datepicker
        Parameters:
        target - An AjaxRequestTarget
      • refresh

        public void refresh​(org.apache.wicket.ajax.AjaxRequestTarget target)
      • enable

        public void enable​(org.apache.wicket.ajax.AjaxRequestTarget target)
        Enable the datepicker
        Parameters:
        target - An AjaxRequestTarget
      • getCssResources

        public org.wicketstuff.jwicket.JQueryCssResourceReference[] getCssResources()
        Specified by:
        getCssResources in interface org.wicketstuff.jwicket.IStyleResolver