@JavaScript(value="frontend://timepickerConnector.js") @JsModule(value="./timepickerConnector.js") public class TimePicker extends GeneratedVaadinTimePicker<TimePicker,LocalTime> implements HasSize, HasValidation, HasEnabled, HasHelper
vaadin-time-picker
web component.GeneratedVaadinTimePicker.InvalidChangeEvent<R extends GeneratedVaadinTimePicker<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 |
---|
TimePicker()
Default constructor.
|
TimePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>> listener)
Convenience constructor to create a time picker with a
ValueChangeListener . |
TimePicker(LocalTime time)
Convenience constructor to create a time picker with a pre-selected time.
|
TimePicker(String label)
Convenience constructor to create a time picker with a label.
|
TimePicker(String label,
LocalTime time)
Convenience constructor to create a time picker with a pre-selected time
and a label.
|
Modifier and Type | Method and Description |
---|---|
Registration |
addInvalidChangeListener(ComponentEventListener<GeneratedVaadinTimePicker.InvalidChangeEvent<TimePicker>> listener)
Adds a listener for
invalid-changed events fired by the
webcomponent. |
String |
getErrorMessage()
Gets the current error message from the time picker.
|
String |
getLabel()
Gets the label of the time picker.
|
Locale |
getLocale()
Gets the Locale for this time picker.
|
String |
getMax()
Deprecated.
use
getMaxTime() instead. |
LocalTime |
getMaxTime()
Gets the maximum time in the time picker.
|
String |
getMin()
Deprecated.
use
getMinTime() instead. |
LocalTime |
getMinTime()
Gets the minimum time in the time picker.
|
String |
getPlaceholder()
Gets the placeholder of the time picker.
|
Duration |
getStep()
Gets the step of the time picker.
|
static Stream<Locale> |
getSupportedAvailableLocales()
Returns a stream of all the available locales that are supported by the
time picker component.
|
boolean |
isAutoOpen()
Gets whether dropdown will open automatically or not.
|
boolean |
isClearButtonVisible()
Gets whether this time picker displays a clear button when it has value.
|
boolean |
isInvalid()
Gets the validity of the time picker output.
|
boolean |
isRequired()
Determines whether the time picker is marked as input required.
|
protected void |
onAttach(AttachEvent attachEvent)
Called when the component is attached to a UI.
|
void |
setAutoOpen(boolean autoOpen)
Enables or disables the dropdown opening automatically.
|
void |
setClearButtonVisible(boolean clearButtonVisible)
Sets displaying a clear button in the time picker when it has value.
|
void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
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 Time Picker.
|
void |
setMax(String max)
Deprecated.
use
setMaxTime(LocalTime) instead. |
void |
setMaxTime(LocalTime max)
Sets the maximum time in the time picker.
|
void |
setMin(String min)
Deprecated.
use
setMinTime(LocalTime) instead. |
void |
setMinTime(LocalTime min)
Sets the minimum time in the time picker.
|
void |
setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
|
void |
setRequired(boolean required)
Description copied from corresponding location in WebComponent:
|
void |
setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Sets the required indicator visible or not.
|
void |
setStep(Duration step)
Sets the
step property of the time picker using duration. |
void |
setValue(LocalTime value)
Sets the selected time value of the component.
|
protected void |
validate()
Performs server-side validation of the current value.
|
checkValidity, getErrorMessageString, getI18nJsonObject, getLabelString, getMaxString, getMinString, getNameString, getPatternString, getPlaceholderString, getStepDouble, isAutofocusBoolean, isClearButtonVisibleBoolean, isDisabledBoolean, isInvalidBoolean, isPreventInvalidInputBoolean, isReadonlyBoolean, isRequiredBoolean, setAutofocus, setDisabled, setI18n, setName, setPattern, setPreventInvalidInput, setReadonly, setStep
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getParent, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
isEnabled, setEnabled
getHelperComponent, getHelperText, setHelperComponent, setHelperText
getElement
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isReadOnly, isRequiredIndicatorVisible, setReadOnly
clear, getOptionalValue
addAttachListener
addDetachListener
public TimePicker()
public TimePicker(LocalTime time)
time
- the pre-selected time in the pickerpublic TimePicker(String label)
label
- the label describing the time pickersetLabel(String)
public TimePicker(String label, LocalTime time)
label
- the label describing the time pickertime
- the pre-selected time in the pickerpublic TimePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>> listener)
ValueChangeListener
.listener
- the listener to receive value change eventsAbstractField.addValueChangeListener(HasValue.ValueChangeListener)
public void setLabel(String label)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
The label for this element.
setLabel
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
label
- the String value to setpublic void setValue(LocalTime value)
The value will be truncated to millisecond precision, as that is the
maximum that the time picker supports. This means that
AbstractField.getValue()
might return a different value than what was passed
in.
setValue
in interface HasValue<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>,LocalTime>
setValue
in class AbstractField<TimePicker,LocalTime>
value
- the LocalTime instance representing the selected time, or nullpublic String getLabel()
label
property of the time pickerpublic void setErrorMessage(String errorMessage)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
The error message to display when the input is invalid.
setErrorMessage
in interface HasValidation
setErrorMessage
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
errorMessage
- the String value to setpublic String getErrorMessage()
getErrorMessage
in interface HasValidation
public void setInvalid(boolean invalid)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
Set to true if the value is invalid.
setInvalid
in interface HasValidation
setInvalid
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
invalid
- the boolean value to setpublic boolean isInvalid()
return true, if the value is invalid.
isInvalid
in interface HasValidation
validity
property from the time pickerpublic void setPlaceholder(String placeholder)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
A placeholder string in addition to the label.
setPlaceholder
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
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 time pickerpublic void setRequired(boolean required)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
Set to true to mark the input as required.
setRequired
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
required
- the boolean value to setpublic void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
HasValue
If set visible, it is visually indicated in the user interface.
The method is intended to be used with Binder
which does
server-side validation. In case HTML element has its own (client-side)
validation it should be disabled when
setRequiredIndicatorVisible(true)
is called and re-enabled
back on setRequiredIndicatorVisible(false)
. It's
responsibility of each component implementation to follow the contract so
that the method call doesn't do anything else than show/hide the
"required" indication. Usually components provide their own
setRequired
method which should be called in case the
client-side validation is required.
setRequiredIndicatorVisible
in interface HasValue<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>,LocalTime>
setRequiredIndicatorVisible
in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>,LocalTime>
requiredIndicatorVisible
- true
to make the required indicator visible,
false
if notpublic 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 setStep(Duration step)
step
property of the time picker using duration. It
specifies the intervals for the displayed items in the time picker
dropdown and also the displayed time format.
The set step needs to evenly divide a day or an hour and has to be larger
than 0 milliseconds. By default, the format is hh:mm
(same as *
Duration.ofHours(1)
If the step is less than 60 seconds, the format will be changed to
hh:mm:ss
and it can be in hh:mm:ss.fff
format, when the
step is less than 1 second.
NOTE: If the step is less than 900 seconds, the dropdown is hidden.
NOTE: changing the step to a larger duration can cause a new
HasValue.ValueChangeEvent
to be fired
if some parts (eg. seconds) is discarded from the value.
step
- the step to set, not null
and should divide a day or
an hour evenlypublic Duration getStep()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
step
property from the picker, unit secondspublic Registration addInvalidChangeListener(ComponentEventListener<GeneratedVaadinTimePicker.InvalidChangeEvent<TimePicker>> listener)
GeneratedVaadinTimePicker
invalid-changed
events fired by the
webcomponent.addInvalidChangeListener
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
listener
- the listenerRegistration
for removing the event listenerprotected void validate()
validate
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
protected void onAttach(AttachEvent attachEvent)
Component
The default implementation does nothing.
This method is invoked before the AttachEvent
is fired for the
component.
public void setLocale(Locale locale)
By default, the locale is null
until the component is attached to
an UI, and then locale is set to UI.getLocale()
, unless a locale
has been explicitly set before that.
The time formatting is done in the browser using the Date.toLocaleTimeString() function.
If for some reason the browser doesn't support the given locale, the en-US locale is used.
NOTE: only the language + country/region codes are used. This
means that the script and variant information is not used and supported.
NOTE: timezone related data is not supported. NOTE: changing
the locale does not cause a new
HasValue.ValueChangeEvent
to be
fired.
locale
- the locale set to the time picker, cannot be [@code null}public Locale getLocale()
By default, the locale is null
until the component is attached to
an UI, and then locale is set to UI.getLocale()
, unless
setLocale(Locale)
has been explicitly called before that.
@Deprecated public void setMin(String min)
setMinTime(LocalTime)
instead.setMin
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
min
- the minimum time that is allowed to be selected, or
null
to remove any minimum constraintspublic void setMinTime(LocalTime min)
min
- the minimum time that is allowed to be selected, or
null
to remove any minimum constraints@Deprecated public String getMin()
getMinTime()
instead.null
if there's no minimumpublic LocalTime getMinTime()
null
if there's no minimum@Deprecated public void setMax(String max)
setMaxTime(LocalTime)
instead.setMax
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
max
- the maximum time that is allowed to be selected, or
null
to remove any maximum constraintspublic void setMaxTime(LocalTime max)
max
- the maximum time that is allowed to be selected, or
null
to remove any maximum constraints@Deprecated public String getMax()
getMaxTime()
instead.null
if there's no maximumpublic LocalTime getMaxTime()
null
if there's no maximumpublic void setClearButtonVisible(boolean clearButtonVisible)
The clear button is an icon, which can be clicked to set the time picker
value to null
.
setClearButtonVisible
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
clearButtonVisible
- true
to display the clear button, false
to
hide itpublic boolean isClearButtonVisible()
true
if this time picker displays a clear button,
false
otherwisesetClearButtonVisible(boolean)
public void setAutoOpen(boolean autoOpen)
false
the dropdown is only opened when clicking the toggle button or pressing
Up or Down arrow keys.autoOpen
- false
to prevent the dropdown from opening
automaticallypublic boolean isAutoOpen()
false
otherwisepublic static Stream<Locale> getSupportedAvailableLocales()
This is a shorthand for Locale.getAvailableLocales()
where all
locales without the Locale.getLanguage()
have been filtered out,
as the browser cannot localize the time for those.
setLocale(Locale)
,
Locale.getAvailableLocales()
,
Locale.getLanguage()
Copyright © 2022. All rights reserved.