Class EnhancedDateRangePicker
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker,,DateRange>, DateRange> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker,,DateRange>, DateRange> com.vaadin.flow.component.shared.HasClearButton,Serializable
vaadin-date-picker webcomponent.
It allows setting and getting LocalDate objects, setting minimum and
maximum date ranges and has internationalization support by using the
EnhancedDateRangePicker.DatePickerI18n object.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe internationalization properties forEnhancedDateRangePicker.static classinvalid-changedevent is sent when the invalid state changes.static classopened-changedevent is sent when the overlay opened state changes.Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.EnhancedDateRangePicker(DateRange initialDate) Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern.EnhancedDateRangePicker(DateRange initialDate, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern and aHasValue.ValueChangeListener.EnhancedDateRangePicker(DateRange initialDate, String formattingPattern) Convenience Constructor to create a date picker with pre-selected date and pattern setup.EnhancedDateRangePicker(DateRange initialDate, String formattingPattern, String... parserPatterns) Convenience Constructor to create a date picker with pre-selected date, formatting pattern, and parsing patterns.EnhancedDateRangePicker(DateRange initialDate, Locale locale) Convenience Constructor to create a date picker with pre-selected date and locale setup.EnhancedDateRangePicker(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with aHasValue.ValueChangeListener.EnhancedDateRangePicker(String label) Convenience constructor to create a date picker with a label.EnhancedDateRangePicker(String label, DateRange initialDate) Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern and a label.EnhancedDateRangePicker(String label, DateRange initialDate, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern, aHasValue.ValueChangeListenerand a label.EnhancedDateRangePicker(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with aHasValue.ValueChangeListenerand a label. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(com.vaadin.flow.component.Component... components) com.vaadin.flow.shared.RegistrationaddInvalidChangeListener(com.vaadin.flow.component.ComponentEventListener<EnhancedDateRangePicker.InvalidChangeEvent> listener) Adds a listener forinvalid-changedevents fired by the webcomponent.com.vaadin.flow.shared.RegistrationaddOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<EnhancedDateRangePicker.OpenedChangeEvent> listener) Adds a listener foropened-changedevents fired by the webcomponent.protected voidclose()Closes the datepicker overlay.voidDeprecated.protected StringGets the end placeholder of the datepicker.Gets the current error message from the datepicker.getI18n()Gets the internationalization object previously set for this component.Get the visible date when there is no value selected.getLabel()Gets the label of the datepicker.Gets the Locale for this date pickergetMax()Gets the maximum date in the date picker.getMin()Gets the minimum date in the date picker.getName()Gets the name of the EnhancedDatePicker.String[]Gets the parser patterns for this date-pickerGets the Pattern for this date pickerGets the placeholder of the datepicker.com.vaadin.flow.component.ComponentGets the component in the prefix slot of this field.booleanWhen auto open is enabled, the dropdown will open when the field is clicked.booleanGets the validity of the datepicker output.booleanisOpened()Gets the states of the drop-down for the datepickerbooleanDetermines whether the datepicker is marked as input required.booleanReturns whether the side panel is currently visible in the date range picker.booleanReturns whether the text fields are currently visible in the date range picker.booleanGet the state ofshowWeekNumbersproperty of the datepickerprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) voidopen()Opens the datepicker overlay.voidopenOnPosition(int x, int y) Opens the datepicker overlay.voidremove(com.vaadin.flow.component.Component... components) Removes the given child components from this component.voidRemoves all contents from this component, this includes child components, text content as well as child elements that have been added directly to this component using theAPI.invalid reference
ElementvoidremovePresetByIds(String... ids) voidsetAutoOpen(boolean autoOpen) When auto open is enabled, the dropdown will open when the field is clicked.voidsetClassNameForDates(String className, LocalDate... dates) protected voidsetEndPlaceholder(String endPlaceholder) voidsetErrorMessage(String errorMessage) voidSets the internationalization properties for this component.voidsetInitialPosition(LocalDate initialPosition) Date which should be visible when there is no value selected.voidsetInvalid(boolean invalid) voidvoidSet the Locale for the Date Picker.voidSets the maximum date in the date picker.voidSets the minimum date in the date picker.voidvoidsetParsers(String... parserPatterns) Setting the patterns for parsing the value of the date-picker.voidsetPattern(String formattingPattern) Setting the Pattern for formatting value of the date pickervoidsetPlaceholder(String placeholder) voidsetPrefixComponent(com.vaadin.flow.component.Component component) Adds the given component into this field before the content, replacing any existing prefix component.voidsetRequired(boolean required) voidsetRequiredIndicatorVisible(boolean required) voidsetSidePanelVisible(boolean sidePanelVisible) Sets the visibility of the side panel in the date range picker.voidsetTextFieldsVisible(boolean textFieldsVisible) Sets the visibility of the text fields in the date range picker.voidvoidsetWeekNumbersVisible(boolean weekNumbersVisible) Set the week number visible in the EnhancedDatePicker.protected voidvalidate()Performs server-side validation of the current value.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getValue, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisibleMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, removeMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly
-
Field Details
-
PRESET_TODAY
- See Also:
-
PRESET_YESTERDAY
- See Also:
-
PRESET_THIS_WEEK
- See Also:
-
PRESET_LAST_WEEK
- See Also:
-
PRESET_THIS_MONTH
- See Also:
-
PRESET_LAST_MONTH
- See Also:
-
PRESET_THIS_YEAR
- See Also:
-
PRESET_LAST_YEAR
- See Also:
-
PRESET_CANCEL_BUTTON
- See Also:
-
-
Constructor Details
-
EnhancedDateRangePicker
public EnhancedDateRangePicker()Default constructor. -
EnhancedDateRangePicker
Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern.- Parameters:
initialDate- the pre-selected date in the picker- See Also:
-
EnhancedDateRangePicker
Convenience constructor to create a date picker with a label.- Parameters:
label- the label describing the date picker- See Also:
-
EnhancedDateRangePicker
Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern and a label.- Parameters:
label- the label describing the date pickerinitialDate- the pre-selected date in the picker- See Also:
-
EnhancedDateRangePicker
public EnhancedDateRangePicker(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with aHasValue.ValueChangeListener.- Parameters:
listener- the listener to receive value change events- See Also:
-
EnhancedDateRangePicker
public EnhancedDateRangePicker(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with aHasValue.ValueChangeListenerand a label.- Parameters:
label- the label describing the date pickerlistener- the listener to receive value change events- See Also:
-
EnhancedDateRangePicker
public EnhancedDateRangePicker(DateRange initialDate, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern and aHasValue.ValueChangeListener.- Parameters:
initialDate- the pre-selected date in the pickerlistener- the listener to receive value change events- See Also:
-
EnhancedDateRangePicker
public EnhancedDateRangePicker(String label, DateRange initialDate, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker, DateRange>> listener) Convenience constructor to create a date picker with a pre-selected date in current UI locale setPattern, aHasValue.ValueChangeListenerand a label.- Parameters:
label- the label describing the date pickerinitialDate- the pre-selected date in the pickerlistener- the listener to receive value change events- See Also:
-
EnhancedDateRangePicker
Convenience Constructor to create a date picker with pre-selected date and locale setup.- Parameters:
initialDate- the pre-selected date in the pickerlocale- the locale for the date picker
-
EnhancedDateRangePicker
Convenience Constructor to create a date picker with pre-selected date and pattern setup.- Parameters:
initialDate- the pre-selected date in the pickerformattingPattern- the pattern for formatting value of the date picker
-
EnhancedDateRangePicker
public EnhancedDateRangePicker(DateRange initialDate, String formattingPattern, String... parserPatterns) Convenience Constructor to create a date picker with pre-selected date, formatting pattern, and parsing patterns.- Parameters:
initialDate- the pre-selected date in the pickerformattingPattern- the pattern for formatting value of the date pickerparserPatterns- the array of patterns used for parsing the date picker's value
-
-
Method Details
-
disableClientValidation
Deprecated.EnhancedDatePicker has workaround to this issue https://github.com/vaadin/vaadin-date-picker-flow/issues/223 Calling disableClientValidation() after instantiation will make EnhancedDatePicker to behave similar way as regular DatePicker with client side validations. This method is provided if you need to retain that behavior instead. -
setMin
Sets the minimum date in the date picker. Dates before that will be disabled in the popup.- Parameters:
min- the minimum date that is allowed to be selected, ornullto remove any minimum constraints
-
getMin
Gets the minimum date in the date picker. Dates before that will be disabled in the popup.- Returns:
- the minimum date that is allowed to be selected, or
nullif there's no minimum
-
setMax
Sets the maximum date in the date picker. Dates after that will be disabled in the popup.- Parameters:
max- the maximum date that is allowed to be selected, ornullto remove any maximum constraints
-
getMax
Gets the maximum date in the date picker. Dates after that will be disabled in the popup.- Returns:
- the maximum date that is allowed to be selected, or
nullif there's no maximum
-
setLocale
Set the Locale for the Date Picker. The displayed date will be matched to the format used in that locale. If this method is never called, the Locale will default to the UI's Locale.NOTE:Supported formats are MM/DD/YYYY, DD/MM/YYYY and YYYY/MM/DD. Browser compatibility can be different based on the browser and mobile devices, you can check here for more details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
- Parameters:
locale- the locale set to the date picker, cannot be null
-
getLocale
Gets the Locale for this date picker- Overrides:
getLocalein classcom.vaadin.flow.component.Component- Returns:
- the locale used for this picker
-
setParsers
Setting the patterns for parsing the value of the date-picker. The parsing will be attempted according to the order of the supplied patterns. If none of these patterns can successfully parse the date-picker's value, the parsing will, first, be attempted using the formatting value (which can be set using @setPattern). If the latter also fails, parsing will be attempted using the Locale (which can be set using @setLocale).- Parameters:
parserPatterns- the array of patterns used for parsing the date picker's value
-
getParsers
Gets the parser patterns for this date-picker- Returns:
- an array of the parser patterns used for formatting value of the date picker
-
setPattern
Setting the Pattern for formatting value of the date picker- Parameters:
formattingPattern- the pattern for formatting value of the date picker if set to null or empty string then for matting will be done by Locale
-
setClassNameForDates
-
getPattern
Gets the Pattern for this date picker- Returns:
- the pattern for formatting value of the date picker
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
getI18n
Gets the internationalization object previously set for this component.Note: updating the object content that is gotten from this method will not update the lang on the component if not set back using
setI18n(DatePickerI18n)- Returns:
- the i18n object. It will be
null, If the i18n properties weren't set.
-
setI18n
Sets the internationalization properties for this component.- Parameters:
i18n- the internationalized properties, notnull
-
setErrorMessage
- Specified by:
setErrorMessagein interfacecom.vaadin.flow.component.HasValidation
-
getErrorMessage
Gets the current error message from the datepicker.- Specified by:
getErrorMessagein interfacecom.vaadin.flow.component.HasValidation- Returns:
- the current error message
-
setInvalid
public void setInvalid(boolean invalid) - Specified by:
setInvalidin interfacecom.vaadin.flow.component.HasValidation
-
isInvalid
public boolean isInvalid()Gets the validity of the datepicker output.return true, if the value is invalid.
- Specified by:
isInvalidin interfacecom.vaadin.flow.component.HasValidation- Returns:
- the
validityproperty from the datepicker
-
setSidePanelVisible
public void setSidePanelVisible(boolean sidePanelVisible) Sets the visibility of the side panel in the date range picker.The side panel typically includes shortcuts or additional controls.
- Parameters:
sidePanelVisible-trueto show the side panel,falseto hide it
-
isTextFieldsVisible
public boolean isTextFieldsVisible()Returns whether the text fields are currently visible in the date range picker.- Returns:
trueif the text fields are visible,falseotherwise- See Also:
-
setTextFieldsVisible
public void setTextFieldsVisible(boolean textFieldsVisible) Sets the visibility of the text fields in the date range picker.Text fields allow manual entry of the date values.
- Parameters:
textFieldsVisible-trueto show the text fields,falseto hide them
-
isSidePanelVisible
public boolean isSidePanelVisible()Returns whether the side panel is currently visible in the date range picker.- Returns:
trueif the side panel is visible,falseotherwise- See Also:
-
setLabel
- Specified by:
setLabelin interfacecom.vaadin.flow.component.HasLabel
-
getLabel
Gets the label of the datepicker.- Specified by:
getLabelin interfacecom.vaadin.flow.component.HasLabel- Returns:
- the
labelproperty of the datePicker
-
setPlaceholder
-
setEndPlaceholder
-
getPlaceholder
Gets the placeholder of the datepicker.This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Returns:
- the
placeholderproperty of the datePicker
-
getEndPlaceholder
Gets the end placeholder of the datepicker.This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Returns:
- the
placeholderproperty of the datePicker
-
setInitialPosition
Date which should be visible when there is no value selected.The same date formats as for the
valueproperty are supported.- Parameters:
initialPosition- the LocalDate value to set
-
getInitialPosition
Get the visible date when there is no value selected.The same date formats as for the
valueproperty are supported.This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Returns:
- the
initialPositionproperty from the datepicker
-
setRequired
public void setRequired(boolean required) -
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean required) - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker,DateRange>, DateRange> - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker,DateRange>, DateRange>
-
isRequired
public boolean isRequired()Determines whether the datepicker is marked as input required.This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Returns:
trueif the input is required,falseotherwise
-
setWeekNumbersVisible
public void setWeekNumbersVisible(boolean weekNumbersVisible) Set the week number visible in the EnhancedDatePicker.Set true to display ISO-8601 week numbers in the calendar.
Notice that displaying week numbers is only supported when i18n.firstDayOfWeek is 1 (Monday).
- Parameters:
weekNumbersVisible- the boolean value to set
-
isWeekNumbersVisible
public boolean isWeekNumbersVisible()Get the state ofshowWeekNumbersproperty of the datepickerThis property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Returns:
- the
showWeekNumbersproperty from the datepicker
-
open
public void open()Opens the datepicker overlay. -
openOnPosition
public void openOnPosition(int x, int y) Opens the datepicker overlay. -
close
protected void close()Closes the datepicker overlay. -
isOpened
public boolean isOpened()Gets the states of the drop-down for the datepicker- Returns:
trueif the drop-down is opened,falseotherwise
-
setAutoOpen
public void setAutoOpen(boolean autoOpen) When auto open is enabled, the dropdown will open when the field is clicked.- Parameters:
autoOpen- Value for the auto open property,
-
isAutoOpen
public boolean isAutoOpen()When auto open is enabled, the dropdown will open when the field is clicked.- Returns:
trueif auto open is enabled.falseotherwise. Default istrue
-
setName
-
validate
protected void validate()Performs server-side validation of the current value. This is needed because it is possible to circumvent the client-side validation constraints using browser development tools. -
getName
Gets the name of the EnhancedDatePicker.- Returns:
- the
nameproperty from the EnhancedDatePicker
-
addOpenedChangeListener
public com.vaadin.flow.shared.Registration addOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<EnhancedDateRangePicker.OpenedChangeEvent> listener) Adds a listener foropened-changedevents fired by the webcomponent.- Parameters:
listener- the listener- Returns:
- a
Registrationfor removing the event listener
-
addInvalidChangeListener
public com.vaadin.flow.shared.Registration addInvalidChangeListener(com.vaadin.flow.component.ComponentEventListener<EnhancedDateRangePicker.InvalidChangeEvent> listener) Adds a listener forinvalid-changedevents fired by the webcomponent.- Parameters:
listener- the listener- Returns:
- a
Registrationfor removing the event listener
-
setPrefixComponent
public void setPrefixComponent(com.vaadin.flow.component.Component component) Adds the given component into this field before the content, replacing any existing prefix component.This is most commonly used to add a simple icon or static text into the field.
- Parameters:
component- the component to set, can benullto remove existing prefix component
-
getPrefixComponent
public com.vaadin.flow.component.Component getPrefixComponent()Gets the component in the prefix slot of this field.- Returns:
- the prefix component of this field, or
nullif no prefix component has been set - See Also:
-
removeAll
public void removeAll()Removes all contents from this component, this includes child components, text content as well as child elements that have been added directly to this component using theAPI.invalid reference
Element- Specified by:
removeAllin interfacecom.vaadin.flow.component.HasComponents
-
remove
public void remove(com.vaadin.flow.component.Component... components) Removes the given child components from this component.- Specified by:
removein interfacecom.vaadin.flow.component.HasComponents- Parameters:
components- The components to remove.- Throws:
IllegalArgumentException- if any of the components is not a child of this component.
-
add
public void add(com.vaadin.flow.component.Component... components) - Specified by:
addin interfacecom.vaadin.flow.component.HasComponents
-
removePresetByIds
-
setValue
- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker,DateRange>, DateRange> - Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<EnhancedDateRangePicker,DateRange>
-
getEmptyValue
- Specified by:
getEmptyValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EnhancedDateRangePicker,DateRange>, DateRange> - Overrides:
getEmptyValuein classcom.vaadin.flow.component.AbstractField<EnhancedDateRangePicker,DateRange>
-