Class Select<T>
- Type Parameters:
T- the type of the items for the select
- All Implemented Interfaces:
AttachNotifier,BlurNotifier<Select<T>>,DetachNotifier,Focusable<Select<T>>,FocusNotifier<Select<T>>,HasAriaLabel,HasComponents,HasElement,HasEnabled,HasHelper,HasLabel,HasSize,HasStyle,HasTheme,HasValidation,HasValue<AbstractField.ComponentValueChangeEvent<Select<T>,,T>, T> HasValueAndElement<AbstractField.ComponentValueChangeEvent<Select<T>,,T>, T> HasClientValidation,HasOverlayClassName,HasPrefix,HasThemeVariant<SelectVariant>,HasTooltip,HasValidationProperties,HasItemComponents<T>,HasValidator<T>,HasDataView<T,,Void, SelectDataView<T>> HasListDataView<T,,SelectListDataView<T>> SingleSelect<Select<T>,,T> Serializable
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic 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
AbstractField.ComponentValueChangeEvent<C extends Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasClientValidation
HasClientValidation.ClientValidatedEventNested classes/interfaces inherited from interface com.vaadin.flow.data.binder.HasItemComponents
HasItemComponents.ItemComponent<T>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSelect()Constructs a select.Constructs a select with the initial value change listener.Select(String label, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Select<T>, T>> listener) Constructs a select with the initial label text and value change listener.Select(String label, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Select<T>, T>> listener, T... items) Constructs a select with the initial label text and value change listener. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given components as children of this component.voidaddComponentAsFirst(Component component) Adds the given component as the first child of this component.voidaddComponentAtIndex(int index, Component component) Adds the given component as child of this component at the specific index.voidaddComponents(T afterItem, Component... components) Adds the components after the given item.protected RegistrationAdds a listener forinvalid-changedevents fired by the webcomponent.protected RegistrationAdds a listener foropened-changedevents fired by the webcomponent.Enables the implementing components to notify changes in their validation status to the observers.Gets the aria-label of the component.Gets the aria-labelledby of the componentGets the child components of this component.DataProvider<T,?> Gets the data provider.Gets the generic data view for theSelect.Returns the item enabled predicate.Gets the item label generator.intgetItemPosition(T item) Gets the index of the child element that represents the given item.ComponentRenderer<? extends Component,T> Returns the item component renderer.getLabel()Gets the string for the label element.Gets the list data view for theSelect.Gets the placeholder hint set for the user.protected booleanChecks whether the element property has a value that can be converted to the model type.booleanGets whether this select has been set to autofocus when the page loads.booleanReturns whether the user is allowed to select nothing.protected booleanisOpened()Whether the dropdown is opened or not.booleanChecks whether the required indicator is visible.protected voidonAttach(AttachEvent attachEvent) Called when the component is attached to a UI.voidonEnabledStateChanged(boolean enabled) Handle component enable state when the enabled state changes.voidprependComponents(T beforeItem, Component... components) Adds the components before the given item.voidRemoves the given child components from this component.voidRemoves all child components that are not items.voidsetAriaLabel(String ariaLabel) Set the aria-label of the component to the given text.voidsetAriaLabelledBy(String ariaLabelledBy) Set the aria-labelledby of the component.voidsetAutofocus(boolean autofocus) Sets the select to have focus when the page loads.voidsetEmptySelectionAllowed(boolean emptySelectionAllowed) Sets whether the user is allowed to select nothing.voidsetEmptySelectionCaption(String emptySelectionCaption) Sets the empty selection caption whensetEmptySelectionAllowed(boolean)has been enabled.voidsetItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider) Sets the item enabled predicate for this select.voidsetItemLabelGenerator(ItemLabelGenerator<T> itemLabelGenerator) Sets the item label generator.setItems(DataProvider<T, Void> dataProvider) Set a generic data provider for the component to use and returns the baseDataViewthat provides API to get information on the items.setItems(InMemoryDataProvider<T> inMemoryDataProvider) Sets an in-memory data provider for the component to usesetItems(ListDataProvider<T> dataProvider) Sets a ListDataProvider for the component to use and returns aListDataViewthat provides information and allows operations on the items.voidSets the string for the label element.protected voidsetOpened(boolean opened) Set true to open the dropdown overlay.voidsetPlaceholder(String placeholder) Sets the placeholder hint for the user.voidsetRenderer(ComponentRenderer<? extends Component, T> renderer) Sets the item renderer for this select group.voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible) Sets the required indicator visible or not.voidsetTextRenderer(ItemLabelGenerator<T> itemLabelGenerator) Convenience setter for creating aTextRendererfrom the given function that converts the item to a string.protected voidvalidate()protected booleanvalueEquals(T value1, T value2) Compares two value instances to each other to determine whether they are equal.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValueMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, 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.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, 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.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItems, setItemsMethods inherited from interface com.vaadin.flow.component.shared.HasOverlayClassName
getOverlayClassName, setOverlayClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods 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.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.data.binder.HasValidator
getDefaultValidatorMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, setReadOnly
-
Field Details
-
LABEL_ATTRIBUTE
- See Also:
-
-
Constructor Details
-
Select
public Select()Constructs a select. -
Select
public Select(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Select<T>, T>> listener) Constructs a select with the initial value change listener.- Parameters:
listener- the value change listener to add- See Also:
-
Select
public Select(String label, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Select<T>, T>> listener) Constructs a select with the initial label text and value change listener.- Parameters:
label- the label describing the selectlistener- the value change listener to add- See Also:
-
Select
@SafeVarargs public Select(String label, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Select<T>, T>> listener, T... items) Constructs a select with the initial label text and value change listener.- Parameters:
label- the label describing the selectlistener- the value change listener to additems- the items to be shown in the list of the select- See Also:
-
-
Method Details
-
getItemRenderer
Returns the item component renderer.- Returns:
- the item renderer or
nullif none set - See Also:
-
setRenderer
Sets the item renderer for this select group. The renderer is applied to each item to create a component which represents the item option in the select's drop down.Default is
nullwhich means that the item'sObject.toString()method is used and set as the text content of the vaadin item element.- Parameters:
renderer- the item renderer, ornullto clear
-
setTextRenderer
Convenience setter for creating aTextRendererfrom the given function that converts the item to a string.NOTE: even though this accepts an
ItemLabelGenerator, this is not the same assetItemLabelGenerator(ItemLabelGenerator)which does a different thing.- Parameters:
itemLabelGenerator- the function that creates the text content from the item, notnull
-
setEmptySelectionAllowed
public void setEmptySelectionAllowed(boolean emptySelectionAllowed) Sets whether the user is allowed to select nothing. When settruea special empty item is shown to the user.Default is
false. The empty selection item can be customized withsetEmptySelectionCaption(String).- Parameters:
emptySelectionAllowed-trueto allow not selecting anything,falseto require selection- See Also:
-
isEmptySelectionAllowed
public boolean isEmptySelectionAllowed()Returns whether the user is allowed to select nothing.- Returns:
trueif empty selection is allowed,falseotherwise
-
setEmptySelectionCaption
Sets the empty selection caption whensetEmptySelectionAllowed(boolean)has been enabled. The caption is shown for the empty selection item in the drop down.When the empty selection item is selected, the select shows the value provided by
setItemLabelGenerator(ItemLabelGenerator)for thenullitem, or the string set withsetPlaceholder(String)or an empty string if not placeholder is set.Default is an empty string "", which will show the place holder when selected.
- Parameters:
emptySelectionCaption- the empty selection caption to set, notnull- See Also:
-
getEmptySelectionCaption
-
getItemEnabledProvider
Returns the item enabled predicate.- Returns:
- the item enabled predicate or
nullif not set - See Also:
-
setItemEnabledProvider
Sets the item enabled predicate for this select. The predicate is applied to each item to determine whether the item should be enabled (true) or disabled (false). Disabled items are displayed as grayed out and the user cannot select them.By default is
nulland all the items are enabled.- Parameters:
itemEnabledProvider- the item enable predicate ornullto clear
-
getItemLabelGenerator
Gets the item label generator. It generates the text that is shown in the input part for the item when it has been selected.Default is
null.- Returns:
- the item label generator,
nullif not set
-
setItemLabelGenerator
Sets the item label generator. It generates the text that is shown in the input part for the item when it has been selected.Default is
nulland the text content generated for the item withsetRenderer(ComponentRenderer)is used instead.- Parameters:
itemLabelGenerator- the item label generator to set, ornullto clear
-
getPlaceholder
Gets the placeholder hint set for the user.- Returns:
- the placeholder or
nullif none set
-
setPlaceholder
Sets the placeholder hint for the user.The placeholder will be displayed in the case that there is no item selected, or the selected item has an empty string label, or the selected item has no label and it's DOM content is empty.
Default value is
null.- Parameters:
placeholder- the placeholder to set, ornullto remove
-
setLabel
Sets the string for the label element.NOTE: the label must be set for the required indicator to be visible.
-
getLabel
Gets the string for the label element. -
setAriaLabel
Description copied from interface:HasAriaLabelSet the aria-label of the component to the given text.This method should not be used if
HasAriaLabel.setAriaLabelledBy(String)is also used. If both attributes are present, aria-labelledby will take precedence over aria-label.- Specified by:
setAriaLabelin interfaceHasAriaLabel- Parameters:
ariaLabel- the aria-label text to set ornullto clear
-
getAriaLabel
Description copied from interface:HasAriaLabelGets the aria-label of the component.- Specified by:
getAriaLabelin interfaceHasAriaLabel- Returns:
- an optional aria-label of the component if no aria-label has been set
-
setAriaLabelledBy
Description copied from interface:HasAriaLabelSet the aria-labelledby of the component. The value must be a valid id attribute of another element that labels the component. The label element must be in the same DOM scope of the component, otherwise screen readers may fail to announce the label content properly.This method should not be used if
HasAriaLabel.setAriaLabel(String)is also used. If both attributes are present, aria-labelledby will take precedence over aria-label.- Specified by:
setAriaLabelledByin interfaceHasAriaLabel- Parameters:
ariaLabelledBy- the string with the id of the element that will be used as label ornullto clear
-
getAriaLabelledBy
Description copied from interface:HasAriaLabelGets the aria-labelledby of the component- Specified by:
getAriaLabelledByin interfaceHasAriaLabel- Returns:
- an optional aria-labelledby of the component if no aria-labelledby has been set
-
setAutofocus
public void setAutofocus(boolean autofocus) Sets the select to have focus when the page loads.Default is
false.- Parameters:
autofocus- the autofocus to set
-
isAutofocus
public boolean isAutofocus()Gets whether this select has been set to autofocus when the page loads.- Returns:
trueif set to autofocus,falseif not
-
getDataProvider
Gets the data provider.- Returns:
- the data provider, not
null
-
setItems
Description copied from interface:HasDataViewSet a generic data provider for the component to use and returns the baseDataViewthat provides API to get information on the items.This method should be used only when the data provider type is not either
ListDataProviderorBackEndDataProvider.- Specified by:
setItemsin interfaceHasDataView<T,Void, SelectDataView<T>> - Parameters:
dataProvider- DataProvider instance to use, notnull- Returns:
- DataView providing information on the data
-
setItems
Description copied from interface:HasDataViewSets an in-memory data provider for the component to useNote! Using a
ListDataProviderinstead of aInMemoryDataProvideris recommended to get access toListDataViewAPI by usingHasListDataView.setItems(ListDataProvider).- Specified by:
setItemsin interfaceHasDataView<T,Void, SelectDataView<T>> - Parameters:
inMemoryDataProvider- InMemoryDataProvider to use, notnull- Returns:
- DataView providing information on the data
-
setItems
Description copied from interface:HasListDataViewSets a ListDataProvider for the component to use and returns aListDataViewthat provides information and allows operations on the items.- Specified by:
setItemsin interfaceHasListDataView<T,SelectListDataView<T>> - Parameters:
dataProvider- ListDataProvider providing items to the component.- Returns:
- ListDataView providing access to the items
-
getGenericDataView
Gets the generic data view for theSelect. This data view should only be used whengetListDataView()is not applicable for the underlying data provider.- Specified by:
getGenericDataViewin interfaceHasDataView<T,Void, SelectDataView<T>> - Returns:
- the generic DataView instance implementing
Select
-
getListDataView
Gets the list data view for theSelect. This data view should only be used when the items are in-memory and set with: If the items are not in-memory, an exception is thrown.- Specified by:
getListDataViewin interfaceHasListDataView<T,SelectListDataView<T>> - Returns:
- the list data view that provides access to the data bound to the
Select
-
onEnabledStateChanged
public void onEnabledStateChanged(boolean enabled) Description copied from class:ComponentHandle component enable state when the enabled state changes.By default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.
- Overrides:
onEnabledStateChangedin classComponent- Parameters:
enabled- the new enabled state of the component
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) Sets the required indicator visible or not.If set visible, it is visually indicated in the user interface.
The method is intended to be used with
Binderwhich does server-side validation. In case HTML element has its own (client-side) validation it should be disabled whensetRequiredIndicatorVisible(true)is called and re-enabled back onsetRequiredIndicatorVisible(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 ownsetRequiredmethod which should be called in case the client-side validation is required. NOTE: The required indicator will not be visible, if thesetLabel(String)property is not set for the select.- Specified by:
setRequiredIndicatorVisiblein interfaceHasValue<AbstractField.ComponentValueChangeEvent<Select<T>,T>, T> - Specified by:
setRequiredIndicatorVisiblein interfaceHasValueAndElement<AbstractField.ComponentValueChangeEvent<Select<T>,T>, T> - Parameters:
requiredIndicatorVisible-trueto make the required indicator visible,falseif not
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()Checks whether the required indicator is visible. NOTE: The required indicator will not be visible, if thesetLabel(String)property is not set for the select.- Specified by:
isRequiredIndicatorVisiblein interfaceHasValue<AbstractField.ComponentValueChangeEvent<Select<T>,T>, T> - Specified by:
isRequiredIndicatorVisiblein interfaceHasValueAndElement<AbstractField.ComponentValueChangeEvent<Select<T>,T>, T> - Returns:
trueif visible,falseif not
-
add
Adds the given components as children of this component.In case any of the specified components has already been added to another parent, it will be removed from there and added to this one.
NOTE: If you add a component with the
slotattribute set, it will be placed in the light-dom of thevaadin-selectinstead of the dropdown.- Specified by:
addin interfaceHasComponents- Parameters:
components- the components to add
-
addComponents
Description copied from interface:HasItemComponentsAdds the components after the given item.- Specified by:
addComponentsin interfaceHasItemComponents<T>- Parameters:
afterItem- item to add components aftercomponents- components to add after item
-
prependComponents
Description copied from interface:HasItemComponentsAdds the components before the given item.- Specified by:
prependComponentsin interfaceHasItemComponents<T>- Parameters:
beforeItem- item to add components in front ofcomponents- components to add before item
-
getItemPosition
Description copied from interface:HasItemComponentsGets the index of the child element that represents the given item.- Specified by:
getItemPositionin interfaceHasItemComponents<T>- Parameters:
item- the item to look for- Returns:
- the index of the child element that represents the item, or -1 if the item is not found
-
addComponentAtIndex
Adds the given component as child of this component at the specific index.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
NOTE: If you add a component with the
slotattribute set, it will be placed in the light-dom of thevaadin-selectinstead of the dropdown.- Specified by:
addComponentAtIndexin interfaceHasComponents- Parameters:
index- the index, where the component will be added. The index must be non-negative and may not exceed the children countcomponent- the component to add, value should not be null
-
addComponentAsFirst
Adds the given component as the first child of this component.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
NOTE: If you add a component with the
slotattribute set, it will be placed in the light-dom of thevaadin-selectinstead of the dropdown.- Specified by:
addComponentAsFirstin interfaceHasComponents- Parameters:
component- the component to add, value should not be null
-
getChildren
Description copied from class:ComponentGets the child components of this component.The default implementation finds child components by traversing each child
Elementtree.If the component is injected to a PolymerTemplate using the
@Idannotation the getChildren method will only return children added from the server side and will not return any children declared in the template file.- Overrides:
getChildrenin classComponent- Returns:
- the child components of this component
- See Also:
-
remove
Removes the given child components from this component.NOTE: any component with the
slotattribute will be attempted to removed from the light dom of the vaadin-select, instead of inside the options drop down.- Specified by:
removein interfaceHasComponents- Parameters:
components- the components to remove- Throws:
IllegalArgumentException- if any of the components is not a child of this component
-
removeAll
public void removeAll()Removes all child components that are not items. To remove all items, reset the data provider or useHasListDataView.setItems(Object[]).NOTE: this will remove all non-items from the drop down and any slotted components from vaadin-select's light dom.
- Specified by:
removeAllin interfaceHasComponents- See Also:
-
setOpened
protected void setOpened(boolean opened) Set true to open the dropdown overlay.- Parameters:
opened- the boolean value to set
-
isOpened
Whether the dropdown is opened or not.- Returns:
trueif the drop-down is opened,falseotherwise
-
hasValidValue
protected boolean hasValidValue()Description copied from class:AbstractSinglePropertyFieldChecks whether the element property has a value that can be converted to the model type. Property changes from the element will be ignored if this method returnsfalse. The default implementation always returntrue.- Overrides:
hasValidValuein classAbstractSinglePropertyField<Select<T>,T> - Returns:
trueif the element property value can be converted to the model type; otherwisefalse
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.The default implementation does nothing.
This method is invoked before the
AttachEventis fired for the component. -
valueEquals
Compares two value instances to each other to determine whether they are equal. Equality is used to determine whether to update internal state and fire an event whenAbstractField.setValue(Object)orAbstractField.setModelValue(Object, boolean)is called. Subclasses can override this method to define an alternative comparison method instead ofObject.equals(Object).- Overrides:
valueEqualsin classAbstractField<Select<T>,T> - Parameters:
value1- the first instancevalue2- the second instance- Returns:
trueif the instances are equal; otherwisefalse
-
validate
protected void validate() -
addValidationStatusChangeListener
Description copied from interface:HasValidatorEnables the implementing components to notify changes in their validation status to the observers.Note: This method can be overridden by the implementing classes e.g. components, to enable the associated
Binder.Bindinginstance subscribing for their validation change events and revalidate itself.This method primarily designed for notifying the Binding about the validation status changes of a bound component at the client-side. WebComponents such as
<vaadin-date-picker>or any other component that accept a formatted text as input should be able to communicate their invalid status to their server-side instance, and a bound server-side component instance must notify its binding about this validation status change as well. When the binding instance revalidates, a chain of validators and convertors get executed one of which is the default validator provided byHasValidator.getDefaultValidator(). Thus, In order for the binding to be able to show/clear errors for its associated bound field, it is important that implementing components take that validation status into account while implementing any validator and converter includingHasValidator.getDefaultValidator(). Here is an example:@Tag("date-picker-demo") public class DatePickerDemo implements HasValidator<LocalDate> { // Each web component has a way to communicate its validation status // to its server-side component instance. The following clientSideValid // state is introduced here just for the sake of simplicity of this code // snippet: boolean clientSideValid = true; /** * Note howclientSideValidengaged in the definition * of this method. It is important to reflect this status either * in the returning validation result of this method or any other * validation that is associated with this component. */ @Override public Validator getDefaultValidator() { return (value, valueContext) -> clientSideValid ? ValidationResult.ok() : ValidationResult.error("Invalid date format"); } private final Collection<ValidationStatusChangeListener<LocalDate>> validationStatusListeners = new ArrayList<>(); /** * This enables the binding to subscribe for the validation status * change events that are fired by this component and revalidate * itself respectively. */ @Override public Registration addValidationStatusChangeListener( ValidationStatusChangeListener<LocalDate> listener) { validationStatusListeners.add(listener); return () -> validationStatusListeners.remove(listener); } private void fireValidationStatusChangeEvent( boolean newValidationStatus) { if (this.clientSideValid != newValidationStatus) { this.clientSideValid = newValidationStatus; var event = new ValidationStatusChangeEvent<>(this, newValidationStatus); validationStatusListeners.forEach( listener -> listener.validationStatusChanged(event)); } } }- Specified by:
addValidationStatusChangeListenerin interfaceHasValidator<T>- Returns:
- Registration of the added listener.
- See Also:
-
addOpenedChangeListener
protected Registration addOpenedChangeListener(ComponentEventListener<Select.OpenedChangeEvent> listener) Adds a listener foropened-changedevents fired by the webcomponent.- Parameters:
listener- the listener- Returns:
- a
Registrationfor removing the event listener
-
addInvalidChangeListener
protected Registration addInvalidChangeListener(ComponentEventListener<Select.InvalidChangeEvent> listener) Adds a listener forinvalid-changedevents fired by the webcomponent.- Parameters:
listener- the listener- Returns:
- a
Registrationfor removing the event listener
-