@JsModule(value="./timepickerConnector.js") public class TimePicker extends GeneratedVaadinTimePicker<TimePicker,LocalTime> implements HasSize, HasValidation, HasEnabled
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 |
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 |
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 value of this object.
|
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, setStepgetSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventaddValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeightFull, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFullisEnabled, setEnabledgetElementaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameaddFocusShortcut, blur, focus, getTabIndex, setTabIndexaddBlurListeneraddFocusListenerisReadOnly, isRequiredIndicatorVisible, setReadOnlyclear, getOptionalValueaddAttachListeneraddDetachListenerpublic 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)
GeneratedVaadinTimePickerDescription 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)
HasValuegetValue(), fires a value change event. May throw
IllegalArgumentException if the value is not acceptable.
Implementation note: the implementing class should document
whether null values are accepted or not, and override
HasValue.getEmptyValue() if the empty value is not null.
setValue in interface HasValue<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>,LocalTime>setValue in class AbstractField<TimePicker,LocalTime>value - the new valuepublic String getLabel()
label property of the time pickerpublic void setErrorMessage(String errorMessage)
GeneratedVaadinTimePickerDescription copied from corresponding location in WebComponent:
The error message to display when the input is invalid.
setErrorMessage in interface HasValidationsetErrorMessage in class GeneratedVaadinTimePicker<TimePicker,LocalTime>errorMessage - the String value to setpublic String getErrorMessage()
getErrorMessage in interface HasValidationpublic void setInvalid(boolean invalid)
GeneratedVaadinTimePickerDescription copied from corresponding location in WebComponent:
Set to true if the value is invalid.
setInvalid in interface HasValidationsetInvalid in class GeneratedVaadinTimePicker<TimePicker,LocalTime>invalid - the boolean value to setpublic boolean isInvalid()
return true, if the value is invalid.
isInvalid in interface HasValidationvalidity property from the time pickerpublic void setPlaceholder(String placeholder)
GeneratedVaadinTimePickerDescription 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)
GeneratedVaadinTimePickerDescription 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)
HasValueIf 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)
GeneratedVaadinTimePickerinvalid-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)
ComponentThe 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 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 © 2020. All rights reserved.