@Tag(value="vaadin-date-picker") @HtmlImport(value="frontend://bower_components/vaadin-date-picker/src/vaadin-date-picker.html") @NpmPackage(value="@vaadin/vaadin-date-picker", version="4.4.5") @JsModule(value="@vaadin/vaadin-date-picker/src/vaadin-date-picker.js") public abstract class GeneratedVaadinDatePicker<R extends GeneratedVaadinDatePicker<R,T>,T> extends AbstractSinglePropertyField<R,T> implements HasStyle, Focusable<R>
Description copied from corresponding location in WebComponent:
<vaadin-date-picker>
is a date selection field which includes a
scrollable month calendar view. <vaadin-date-picker
label="Birthday"></vaadin-date-picker>
datePicker.value = '2016-03-02';
When the selected value
is
changed, a value-changed
event is triggered.
The following shadow DOM parts are available for styling:
Part name | Description | Theme for Element |
---|---|---|
text-field |
Input element | vaadin-date-picker |
clear-button |
Clear button | vaadin-date-picker |
toggle-button |
Toggle button | vaadin-date-picker |
overlay-content |
The overlay element | vaadin-date-picker |
overlay-header |
Fullscreen mode header | vaadin-date-picker-overlay-content |
label |
Fullscreen mode value/label | vaadin-date-picker-overlay-content |
clear-button |
Fullscreen mode clear button | vaadin-date-picker-overlay-content |
toggle-button |
Fullscreen mode toggle button | vaadin-date-picker-overlay-content |
years-toggle-button |
Fullscreen mode years scroller toggle | vaadin-date-picker-overlay-content |
months |
Months scroller | vaadin-date-picker-overlay-content |
years |
Years scroller | vaadin-date-picker-overlay-content |
toolbar |
Footer bar with buttons | vaadin-date-picker-overlay-content |
today-button |
Today button | vaadin-date-picker-overlay-content |
cancel-button |
Cancel button | vaadin-date-picker-overlay-content |
month |
Month calendar | vaadin-date-picker-overlay-content |
year-number |
Year number | vaadin-date-picker-overlay-content |
year-separator |
Year separator | vaadin-date-picker-overlay-content |
month-header |
Month title | vaadin-month-calendar |
weekdays |
Weekday container | vaadin-month-calendar |
weekday |
Weekday element | vaadin-month-calendar |
week-numbers |
Week numbers container | vaadin-month-calendar |
week-number |
Week number element | vaadin-month-calendar |
date |
Date element | vaadin-month-calendar |
See ThemableMixin – how to apply styles for shadow parts
The following state attributes are available for styling:
Attribute | Description | Part name |
---|---|---|
invalid |
Set when the element is invalid | :host |
opened |
Set when the date selector overlay is opened | :host |
readonly |
Set when the element is readonly | :host |
disabled |
Set when the element is disabled | :host |
today |
Set on the date corresponding to the current day | date |
focused |
Set on the focused date | date |
disabled |
Set on the date out of the allowed range | date |
selected |
Set on the selected date | date |
If you want to replace the default input field with a custom implementation,
you should use the
<vaadin-date-picker-light>
element.
In addition to <vaadin-date-picker>
itself, the following internal
components are themable:
<vaadin-text-field>
<vaadin-date-picker-overlay>
<vaadin-date-picker-overlay-content>
<vaadin-month-calendar>
Note: the theme
attribute value set on <vaadin-date-picker>
is propagated to the internal themable components listed above.
Modifier and Type | Class and Description |
---|---|
static class |
GeneratedVaadinDatePicker.ChangeEvent<R extends GeneratedVaadinDatePicker<R,?>> |
static class |
GeneratedVaadinDatePicker.InvalidChangeEvent<R extends GeneratedVaadinDatePicker<R,?>> |
static class |
GeneratedVaadinDatePicker.OpenedChangeEvent<R extends GeneratedVaadinDatePicker<R,?>> |
AbstractField.ComponentValueChangeEvent<C extends Component,V>
BlurNotifier.BlurEvent<C extends Component>
FocusNotifier.FocusEvent<C extends Component>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
Constructor and Description |
---|
GeneratedVaadinDatePicker()
Default constructor.
|
GeneratedVaadinDatePicker(T initialValue,
T defaultValue,
boolean acceptNullValues)
Constructs a new GeneratedVaadinDatePicker component with the given
arguments.
|
GeneratedVaadinDatePicker(T initialValue,
T defaultValue,
Class<P> elementPropertyType,
SerializableBiFunction<R,P,T> presentationToModel,
SerializableBiFunction<R,T,P> modelToPresentation)
Constructs a new GeneratedVaadinDatePicker component with the given
arguments.
|
GeneratedVaadinDatePicker(T initialValue,
T defaultValue,
Class<P> elementPropertyType,
SerializableFunction<P,T> presentationToModel,
SerializableFunction<T,P> modelToPresentation)
Constructs a new GeneratedVaadinDatePicker component with the given
arguments.
|
Modifier and Type | Method and Description |
---|---|
protected Registration |
addChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.ChangeEvent<R>> listener)
Adds a listener for
change events fired by the webcomponent. |
protected Registration |
addInvalidChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.InvalidChangeEvent<R>> listener)
Adds a listener for
invalid-changed events fired by the
webcomponent. |
protected Registration |
addOpenedChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.OpenedChangeEvent<R>> listener)
Adds a listener for
opened-changed events fired by the
webcomponent. |
protected void |
addToPrefix(Component... components)
Adds the given components as children of this component at the slot
'prefix'.
|
protected void |
checkValidity(String value)
Description copied from corresponding location in WebComponent:
|
protected void |
close()
Description copied from corresponding location in WebComponent:
|
protected String |
getErrorMessageString()
Description copied from corresponding location in WebComponent:
|
protected elemental.json.JsonObject |
getI18nJsonObject()
Description copied from corresponding location in WebComponent:
|
protected String |
getInitialPositionString()
Description copied from corresponding location in WebComponent:
|
protected String |
getLabelString()
Description copied from corresponding location in WebComponent:
|
protected String |
getMaxAsStringString()
Description copied from corresponding location in WebComponent:
|
protected String |
getMinAsStringString()
Description copied from corresponding location in WebComponent:
|
protected String |
getNameString()
Description copied from corresponding location in WebComponent:
|
protected String |
getPlaceholderString()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isAutofocusBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isClearButtonVisibleBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isDisabledBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isInvalidBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isOpenedBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isReadonlyBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isRequiredBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isShowWeekNumbersBoolean()
Description copied from corresponding location in WebComponent:
|
protected void |
open()
Description copied from corresponding location in WebComponent:
|
protected void |
remove(Component... components)
Removes the given child components from this component.
|
protected 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 the
Element API. |
protected void |
setAutofocus(boolean autofocus)
Description copied from corresponding location in WebComponent:
|
protected void |
setClearButtonVisible(boolean clearButtonVisible)
Description copied from corresponding location in WebComponent:
|
protected void |
setDisabled(boolean disabled)
Description copied from corresponding location in WebComponent:
|
protected void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
protected void |
setI18n(elemental.json.JsonObject i18n)
Description copied from corresponding location in WebComponent:
|
protected void |
setInitialPosition(String initialPosition)
Description copied from corresponding location in WebComponent:
|
protected void |
setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
|
protected void |
setLabel(String label)
Description copied from corresponding location in WebComponent:
|
protected void |
setMaxAsString(String maxAsString)
Description copied from corresponding location in WebComponent:
|
protected void |
setMinAsString(String minAsString)
Description copied from corresponding location in WebComponent:
|
protected void |
setName(String name)
Description copied from corresponding location in WebComponent:
|
protected void |
setOpened(boolean opened)
Description copied from corresponding location in WebComponent:
|
protected void |
setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
|
protected void |
setReadonly(boolean readonly)
Description copied from corresponding location in WebComponent:
|
protected void |
setRequired(boolean required)
Description copied from corresponding location in WebComponent:
|
protected void |
setShowWeekNumbers(boolean showWeekNumbers)
Description copied from corresponding location in WebComponent:
|
protected void |
validate(String value)
Description copied from corresponding location in WebComponent:
|
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isEnabled, setEnabled
getElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
clear, getOptionalValue
addAttachListener
addDetachListener
public GeneratedVaadinDatePicker(T initialValue, T defaultValue, Class<P> elementPropertyType, SerializableFunction<P,T> presentationToModel, SerializableFunction<T,P> modelToPresentation)
P
- the property typeinitialValue
- the initial value to set to the valuedefaultValue
- the default value to use if the value isn't definedelementPropertyType
- the type of the element propertypresentationToModel
- a function that converts a string value to a model valuemodelToPresentation
- a function that converts a model value to a string valuepublic GeneratedVaadinDatePicker(T initialValue, T defaultValue, boolean acceptNullValues)
initialValue
- the initial value to set to the valuedefaultValue
- the default value to use if the value isn't definedacceptNullValues
- whether null
is accepted as a model valuepublic GeneratedVaadinDatePicker(T initialValue, T defaultValue, Class<P> elementPropertyType, SerializableBiFunction<R,P,T> presentationToModel, SerializableBiFunction<R,T,P> modelToPresentation)
P
- the property typeinitialValue
- the initial value to set to the valuedefaultValue
- the default value to use if the value isn't definedelementPropertyType
- the type of the element propertypresentationToModel
- a function that accepts this component and a property value
and returns a model valuemodelToPresentation
- a function that accepts this component and a model value and
returns a property valuepublic GeneratedVaadinDatePicker()
protected boolean isAutofocusBoolean()
Description copied from corresponding location in WebComponent:
Specify that this control should have input focus when the page loads.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
autofocus
property from the webcomponentprotected void setAutofocus(boolean autofocus)
Description copied from corresponding location in WebComponent:
Specify that this control should have input focus when the page loads.
autofocus
- the boolean value to setprotected boolean isDisabledBoolean()
Description copied from corresponding location in WebComponent:
Set to true to disable this element.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
disabled
property from the webcomponentprotected void setDisabled(boolean disabled)
Description copied from corresponding location in WebComponent:
Set to true to disable this element.
disabled
- the boolean value to setprotected boolean isRequiredBoolean()
Description copied from corresponding location in WebComponent:
Set to true to mark the input as required.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
required
property from the webcomponentprotected void setRequired(boolean required)
Description copied from corresponding location in WebComponent:
Set to true to mark the input as required.
required
- the boolean value to setprotected String getNameString()
Description copied from corresponding location in WebComponent:
The name of this element.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
name
property from the webcomponentprotected void setName(String name)
Description copied from corresponding location in WebComponent:
The name of this element.
name
- the String value to setprotected String getInitialPositionString()
Description copied from corresponding location in WebComponent:
Date which should be visible when there is no value selected.
The same date formats as for the value
property 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.
initialPosition
property from the webcomponentprotected void setInitialPosition(String initialPosition)
Description copied from corresponding location in WebComponent:
Date which should be visible when there is no value selected.
The same date formats as for the value
property are supported.
initialPosition
- the String value to setprotected String getLabelString()
Description copied from corresponding location in WebComponent:
The label for this element.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
label
property from the webcomponentprotected void setLabel(String label)
Description copied from corresponding location in WebComponent:
The label for this element.
label
- the String value to set@Synchronize(property="opened", value="opened-changed") protected boolean isOpenedBoolean()
Description copied from corresponding location in WebComponent:
Set true to open the date selector overlay.
This property is synchronized automatically from client side when a 'opened-changed' event happens.
opened
property from the webcomponentprotected void setOpened(boolean opened)
Description copied from corresponding location in WebComponent:
Set true to open the date selector overlay.
opened
- the boolean value to setprotected boolean isShowWeekNumbersBoolean()
Description copied from corresponding location in WebComponent:
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).
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
showWeekNumbers
property from the webcomponentprotected void setShowWeekNumbers(boolean showWeekNumbers)
Description copied from corresponding location in WebComponent:
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).
showWeekNumbers
- the boolean value to setprotected elemental.json.JsonObject getI18nJsonObject()
Description copied from corresponding location in WebComponent:
The object used to localize this component. To change the default localization, replace the entire i18n object or just the property you want to modify.
The object has the following JSON structure and default values:
{
// An array with the full names of months starting
// with January.
monthNames: [
'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December'
],
// An array of weekday names starting with Sunday. Used
// in screen reader announcements.
weekdays: [
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
],
// An array of short weekday names starting with Sunday.
// Displayed in the calendar.
weekdaysShort: [
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
],
// An integer indicating the first day of the week
// (0 = Sunday, 1 = Monday, etc.).
firstDayOfWeek: 0,
// Used in screen reader announcements along with week
// numbers, if they are displayed.
week: 'Week',
// Translation of the Calendar icon button title.
calendar: 'Calendar',
// Translation of the Clear icon button title.
clear: 'Clear',
// Translation of the Today shortcut button text.
today: 'Today',
// Translation of the Cancel button text.
cancel: 'Cancel',
// A function to format given Object
as
// date string. Object is in the format { day: ..., month: ..., year: ... }
// Note: The argument month is 0-based. This means that January = 0 and December = 11.
formatDate: d => {
// returns a string representation of the given
// object in 'MM/DD/YYYY' -format
},
// A function to parse the given text to an Object
in the format { day: ..., month: ..., year: ... }
.
// Must properly parse (at least) text formatted by formatDate
.
// Setting the property to null will disable keyboard input feature.
// Note: The argument month is 0-based. This means that January = 0 and December = 11.
parseDate: text => {
// Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to
// an Object
in the format { day: ..., month: ..., year: ... }
.
}
// A function to format given monthName
and
// fullYear
integer as calendar title string.
formatTitle: (monthName, fullYear) => {
return monthName + ' ' + fullYear;
}
}<p>This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
i18n
property from the webcomponentprotected void setI18n(elemental.json.JsonObject i18n)
Description copied from corresponding location in WebComponent:
The object used to localize this component. To change the default localization, replace the entire i18n object or just the property you want to modify.
The object has the following JSON structure and default values:
{
// An array with the full names of months starting
// with January.
monthNames: [
'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December'
],
// An array of weekday names starting with Sunday. Used
// in screen reader announcements.
weekdays: [
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
],
// An array of short weekday names starting with Sunday.
// Displayed in the calendar.
weekdaysShort: [
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
],
// An integer indicating the first day of the week
// (0 = Sunday, 1 = Monday, etc.).
firstDayOfWeek: 0,
// Used in screen reader announcements along with week
// numbers, if they are displayed.
week: 'Week',
// Translation of the Calendar icon button title.
calendar: 'Calendar',
// Translation of the Clear icon button title.
clear: 'Clear',
// Translation of the Today shortcut button text.
today: 'Today',
// Translation of the Cancel button text.
cancel: 'Cancel',
// A function to format given Object
as
// date string. Object is in the format { day: ..., month: ..., year: ... }
// Note: The argument month is 0-based. This means that January = 0 and December = 11.
formatDate: d => {
// returns a string representation of the given
// object in 'MM/DD/YYYY' -format
},
// A function to parse the given text to an Object
in the format { day: ..., month: ..., year: ... }
.
// Must properly parse (at least) text formatted by formatDate
.
// Setting the property to null will disable keyboard input feature.
// Note: The argument month is 0-based. This means that January = 0 and December = 11.
parseDate: text => {
// Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to
// an Object
in the format { day: ..., month: ..., year: ... }
.
}
// A function to format given monthName
and
// fullYear
integer as calendar title string.
formatTitle: (monthName, fullYear) => {
return monthName + ' ' + fullYear;
}
}
i18n
- the JsonObject value to setprotected String getMinAsStringString()
Description copied from corresponding location in WebComponent:
The earliest date that can be selected. All earlier dates will be disabled.
Supported date formats:
"YYYY-MM-DD"
(default)"+YYYYYY-MM-DD"
,
"-YYYYYY-MM-DD"
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
min
property from the webcomponentprotected void setMinAsString(String minAsString)
Description copied from corresponding location in WebComponent:
The earliest date that can be selected. All earlier dates will be disabled.
Supported date formats:
"YYYY-MM-DD"
(default)"+YYYYYY-MM-DD"
,
"-YYYYYY-MM-DD"
minAsString
- the String value to setprotected String getMaxAsStringString()
Description copied from corresponding location in WebComponent:
The latest date that can be selected. All later dates will be disabled.
Supported date formats:
"YYYY-MM-DD"
(default)"+YYYYYY-MM-DD"
,
"-YYYYYY-MM-DD"
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
max
property from the webcomponentprotected void setMaxAsString(String maxAsString)
Description copied from corresponding location in WebComponent:
The latest date that can be selected. All later dates will be disabled.
Supported date formats:
"YYYY-MM-DD"
(default)"+YYYYYY-MM-DD"
,
"-YYYYYY-MM-DD"
maxAsString
- the String value to setprotected boolean isClearButtonVisibleBoolean()
Description copied from corresponding location in WebComponent:
Set to true to display the clear icon which clears the input.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
clearButtonVisible
property from the webcomponentprotected void setClearButtonVisible(boolean clearButtonVisible)
Description copied from corresponding location in WebComponent:
Set to true to display the clear icon which clears the input.
clearButtonVisible
- the boolean value to setprotected String getErrorMessageString()
Description copied from corresponding location in WebComponent:
The error message to display when the input is invalid.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
errorMessage
property from the webcomponentprotected void setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
The error message to display when the input is invalid.
errorMessage
- the String value to setprotected String getPlaceholderString()
Description copied from corresponding location in WebComponent:
A placeholder string in addition to the label. If this is set, the label will always float.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
placeholder
property from the webcomponentprotected void setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
A placeholder string in addition to the label. If this is set, the label will always float.
placeholder
- the String value to setprotected boolean isReadonlyBoolean()
Description copied from corresponding location in WebComponent:
Set to true to make this element read-only.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
readonly
property from the webcomponentprotected void setReadonly(boolean readonly)
Description copied from corresponding location in WebComponent:
Set to true to make this element read-only.
readonly
- the boolean value to setprotected boolean isInvalidBoolean()
Description copied from corresponding location in WebComponent:
This property is set to true when the control value invalid.
invalid
property from the webcomponentprotected void setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
This property is set to true when the control value invalid.
invalid
- the boolean value to setprotected void open()
Description copied from corresponding location in WebComponent:
Opens the dropdown.
protected void close()
Description copied from corresponding location in WebComponent:
Closes the dropdown.
@NotSupported protected void validate(String value)
Description copied from corresponding location in WebComponent:
Returns true if value
is valid, and sets the invalid
flag
appropriately.
This function is not supported by Flow because it returns a
boolean
. Functions with return types different than void are
not supported at this moment.
value
- Value to validate. Optional, defaults to user's input value.@NotSupported protected void checkValidity(String value)
Description copied from corresponding location in WebComponent:
Returns true if the current input value satisfies all constraints (if any)
Override the checkValidity
method for custom validations.
This function is not supported by Flow because it returns a
boolean
. Functions with return types different than void are
not supported at this moment.
value
- Value to validate. Optional, defaults to the selected date.protected Registration addChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.ChangeEvent<R>> listener)
change
events fired by the webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addInvalidChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.InvalidChangeEvent<R>> listener)
invalid-changed
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addOpenedChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.OpenedChangeEvent<R>> listener)
opened-changed
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected void addToPrefix(Component... components)
components
- The components to add.protected void remove(Component... components)
components
- The components to remove.IllegalArgumentException
- if any of the components is not a child of this component.protected void removeAll()
Element
API.Copyright © 2023. All rights reserved.