@JavaScript(value="frontend://datepickerConnector.js") public class DatePicker extends GeneratedVaadinDatePicker<DatePicker,LocalDate> implements HasSize, HasValidation
vaadin-date-picker
webcomponent.
It allows setting and getting LocalDate
objects, setting minimum and
maximum date ranges and has internationalization support by using the
DatePicker.DatePickerI18n
object.
Modifier and Type | Class and Description |
---|---|
static class |
DatePicker.DatePickerI18n
The internationalization properties for
DatePicker . |
GeneratedVaadinDatePicker.ChangeEvent<R extends GeneratedVaadinDatePicker<R,?>>, GeneratedVaadinDatePicker.InvalidChangeEvent<R extends GeneratedVaadinDatePicker<R,?>>, 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 |
---|
DatePicker()
Default constructor.
|
DatePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
Convenience constructor to create a date picker with a
ValueChangeListener . |
DatePicker(LocalDate initialDate)
Convenience constructor to create a date picker with a pre-selected date
in current UI locale format.
|
DatePicker(LocalDate initialDate,
HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
Convenience constructor to create a date picker with a pre-selected date
in current UI locale format and a
ValueChangeListener . |
DatePicker(LocalDate initialDate,
Locale locale)
Convenience Constructor to create a date picker with pre-selected date
and locale setup.
|
DatePicker(String label)
Convenience constructor to create a date picker with a label.
|
DatePicker(String label,
HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
Convenience constructor to create a date picker with a
ValueChangeListener and a label. |
DatePicker(String label,
LocalDate initialDate)
Convenience constructor to create a date picker with a pre-selected date
in current UI locale format and a label.
|
DatePicker(String label,
LocalDate initialDate,
HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
Convenience constructor to create a date picker with a pre-selected date
in current UI locale format, a
ValueChangeListener and a label. |
Modifier and Type | Method and Description |
---|---|
Registration |
addInvalidChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.InvalidChangeEvent<DatePicker>> listener)
Adds a listener for
invalid-changed events fired by the
webcomponent. |
Registration |
addOpenedChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.OpenedChangeEvent<DatePicker>> listener)
Adds a listener for
opened-changed events fired by the
webcomponent. |
protected void |
close()
Closes the datepicker overlay.
|
String |
getErrorMessage()
Gets the current error message from the datepicker.
|
DatePicker.DatePickerI18n |
getI18n()
Gets the internationalization object previously set for this component.
|
LocalDate |
getInitialPosition()
Get the visible date when there is no value selected.
|
String |
getLabel()
Gets the label of the datepicker.
|
Locale |
getLocale()
Gets the Locale for this date picker
|
LocalDate |
getMax()
Gets the maximum date in the date picker.
|
LocalDate |
getMin()
Gets the minimum date in the date picker.
|
String |
getName()
Gets the name of the DatePicker.
|
String |
getPlaceholder()
Gets the placeholder of the datepicker.
|
boolean |
isInvalid()
Gets the validity of the datepicker output.
|
boolean |
isOpened()
Gets the states of the drop-down for the datepicker
|
boolean |
isRequired()
Determines whether the datepicker is marked as input required.
|
boolean |
isWeekNumbersVisible()
Get the state of
showWeekNumbers property of the datepicker |
protected void |
onAttach(AttachEvent attachEvent)
Called when the component is attached to a UI.
|
void |
open()
Opens the datepicker overlay.
|
void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
void |
setI18n(DatePicker.DatePickerI18n i18n)
Sets the internationalization properties for this component.
|
void |
setInitialPosition(LocalDate initialPosition)
Date which should be visible when there is no value selected.
|
void |
setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
|
void |
setLabel(String label)
Description copied from corresponding location in WebComponent:
|
void |
setLocale(Locale locale)
Set the Locale for the Date Picker.
|
void |
setMax(LocalDate max)
Sets the maximum date in the date picker.
|
void |
setMin(LocalDate min)
Sets the minimum date in the date picker.
|
void |
setName(String name)
Description copied from corresponding location in WebComponent:
|
void |
setOpened(boolean opened)
Sets the opened property of the datepicker to open or close its overlay.
|
void |
setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
|
void |
setRequired(boolean required)
Description copied from corresponding location in WebComponent:
|
void |
setWeekNumbersVisible(boolean weekNumbersVisible)
Set the week number visible in the DatePicker.
|
addChangeListener, addToPrefix, checkValidity, getErrorMessageString, getI18nJsonObject, getInitialPositionString, getLabelString, getMaxAsStringString, getMinAsStringString, getNameString, getPlaceholderString, isAutofocusBoolean, isDisabledBoolean, isInvalidBoolean, isOpenedBoolean, isReadonlyBoolean, isRequiredBoolean, isShowWeekNumbersBoolean, remove, removeAll, setAutofocus, setDisabled, setI18n, setInitialPosition, setMaxAsString, setMinAsString, setReadonly, setShowWeekNumbers, validate
hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHeight, getWidth, setHeight, setSizeFull, setSizeUndefined, setWidth
getElement
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isEnabled, setEnabled
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
clear, getOptionalValue
addAttachListener
addDetachListener
public DatePicker()
public DatePicker(LocalDate initialDate)
initialDate
- the pre-selected date in the pickerAbstractField.setValue(Object)
public DatePicker(String label)
label
- the label describing the date pickersetLabel(String)
public DatePicker(String label, LocalDate initialDate)
label
- the label describing the date pickerinitialDate
- the pre-selected date in the pickerAbstractField.setValue(Object)
,
setLabel(String)
public DatePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
ValueChangeListener
.listener
- the listener to receive value change eventsAbstractField.addValueChangeListener(HasValue.ValueChangeListener)
public DatePicker(String label, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
ValueChangeListener
and a label.label
- the label describing the date pickerlistener
- the listener to receive value change eventssetLabel(String)
,
AbstractField.addValueChangeListener(HasValue.ValueChangeListener)
public DatePicker(LocalDate initialDate, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
ValueChangeListener
.initialDate
- the pre-selected date in the pickerlistener
- the listener to receive value change eventsAbstractField.setValue(Object)
,
AbstractField.addValueChangeListener(HasValue.ValueChangeListener)
public DatePicker(String label, LocalDate initialDate, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DatePicker,LocalDate>> listener)
ValueChangeListener
and a label.label
- the label describing the date pickerinitialDate
- the pre-selected date in the pickerlistener
- the listener to receive value change eventssetLabel(String)
,
AbstractField.setValue(Object)
,
AbstractField.addValueChangeListener(HasValue.ValueChangeListener)
public void setMin(LocalDate min)
min
- the minimum date that is allowed to be selected, or
null
to remove any minimum constraintspublic LocalDate getMin()
null
if there's no minimumpublic void setMax(LocalDate max)
max
- the maximum date that is allowed to be selected, or
null
to remove any maximum constraintspublic LocalDate getMax()
null
if there's no maximumpublic void setLocale(Locale 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
locale
- the locale set to the date picker, cannot be nullpublic Locale getLocale()
protected void onAttach(AttachEvent attachEvent)
Component
The default implementation does nothing.
This method is invoked before the AttachEvent
is fired for the
component.
public DatePicker.DatePickerI18n getI18n()
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)
null
, If the i18n
properties weren't set.public void setI18n(DatePicker.DatePickerI18n i18n)
i18n
- the internationalized properties, not null
public void setErrorMessage(String errorMessage)
GeneratedVaadinDatePicker
Description copied from corresponding location in WebComponent:
The error message to display when the input is invalid.
setErrorMessage
in interface HasValidation
setErrorMessage
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
errorMessage
- the String value to setpublic String getErrorMessage()
getErrorMessage
in interface HasValidation
public void setInvalid(boolean invalid)
GeneratedVaadinDatePicker
Description copied from corresponding location in WebComponent:
This property is set to true when the control value invalid.
setInvalid
in interface HasValidation
setInvalid
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
invalid
- the boolean value to setpublic boolean isInvalid()
return true, if the value is invalid.
isInvalid
in interface HasValidation
validity
property from the datepickerpublic void setLabel(String label)
GeneratedVaadinDatePicker
Description copied from corresponding location in WebComponent:
The label for this element.
setLabel
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
label
- the String value to setpublic String getLabel()
label
property of the datePickerpublic void setPlaceholder(String placeholder)
GeneratedVaadinDatePicker
Description copied from corresponding location in WebComponent:
A placeholder string in addition to the label. If this is set, the label will always float.
setPlaceholder
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
placeholder
- the String value to setpublic String getPlaceholder()
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 of the datePickerpublic void setInitialPosition(LocalDate initialPosition)
The same date formats as for the value
property are supported.
initialPosition
- the LocalDate value to setpublic LocalDate getInitialPosition()
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 datepickerpublic void setRequired(boolean required)
GeneratedVaadinDatePicker
Description copied from corresponding location in WebComponent:
Set to true to mark the input as required.
setRequired
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
required
- the boolean value to setpublic boolean isRequired()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
true
if the input is required, false
otherwisepublic void setWeekNumbersVisible(boolean weekNumbersVisible)
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).
weekNumbersVisible
- the boolean value to setpublic boolean isWeekNumbersVisible()
showWeekNumbers
property 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.
showWeekNumbers
property from the datepickerpublic void setOpened(boolean opened)
setOpened
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
opened
- true
to open the datepicker overlay, false
to
close itpublic void open()
open
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
protected void close()
close
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
public boolean isOpened()
true
if the drop-down is opened, false
otherwisepublic void setName(String name)
GeneratedVaadinDatePicker
Description copied from corresponding location in WebComponent:
The name of this element.
setName
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
name
- the String value to setpublic String getName()
name
property from the DatePickerpublic Registration addOpenedChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.OpenedChangeEvent<DatePicker>> listener)
GeneratedVaadinDatePicker
opened-changed
events fired by the
webcomponent.addOpenedChangeListener
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
listener
- the listenerRegistration
for removing the event listenerpublic Registration addInvalidChangeListener(ComponentEventListener<GeneratedVaadinDatePicker.InvalidChangeEvent<DatePicker>> listener)
GeneratedVaadinDatePicker
invalid-changed
events fired by the
webcomponent.addInvalidChangeListener
in class GeneratedVaadinDatePicker<DatePicker,LocalDate>
listener
- the listenerRegistration
for removing the event listenerCopyright © 2018. All rights reserved.