Class MultiSelectListBox<T>
- Type Parameters:
T- the type of the items contained by this component
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasAriaLabel,HasComponents,HasElement,HasEnabled,HasSize,HasStyle,HasValue<AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,,Set<T>>, Set<T>> HasValueAndElement<AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,,Set<T>>, Set<T>> HasTooltip,HasItemComponents<T>,HasDataView<T,,Void, ListBoxDataView<T>> HasListDataView<T,,ListBoxListDataView<T>> MultiSelect<MultiSelectListBox<T>,,T> Serializable
vaadin-list-box element with
multi-selection.- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
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.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<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSelectionListener(MultiSelectionListener<MultiSelectListBox<T>, T> listener) Adds a selection listener that will be called when the selection is changed either by the user or programmatically.Returns an immutable set of the currently selected items.Gets the selection preservation mode.protected voidsetModelValue(Set<T> newModelValue, boolean fromClient) Updates the model value if the value has actually changed.voidsetSelectionPreservationMode(SelectionPreservationMode selectionPreservationMode) Sets the selection preservation mode.voidSets the value of this component.voidupdateSelection(Set<T> addedItems, Set<T> removedItems) Updates the selection by adding and removing the given items from it.protected booleanvalueEquals(Set<T> value1, Set<T> value2) Compares two value instances to each other to determine whether they are equal.Methods inherited from class com.vaadin.flow.component.listbox.ListBoxBase
bindRequiredIndicatorVisible, getDataProvider, getGenericDataView, getItemEnabledProvider, getItemId, getItemLabelGenerator, getItemRenderer, getListDataView, onAttach, onDetach, onEnabledStateChanged, setDataProvider, setItemEnabledProvider, setItemLabelGenerator, setItems, setItems, setItems, setRenderer, setRequiredIndicatorVisibleMethods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, bindValue, getEmptyValue, getValue, isEmptyMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, 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.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.data.binder.HasItemComponents
addComponents, getItemPosition, prependComponentsMethods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItems, setItemsMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, 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, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, bindValue, clear, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisibleMethods inherited from interface com.vaadin.flow.data.selection.MultiSelect
deselect, deselect, deselectAll, getEmptyValue, getValue, isSelected, select, select
-
Constructor Details
-
MultiSelectListBox
public MultiSelectListBox()Creates a new list box component with multi-selection.
-
-
Method Details
-
setValue
Sets the value of this component. If the new value is not equal to the previous value, fires a value change event.The component doesn't accept
nullvalues. The value of multi select list box without any selected items is an empty set. You can use theHasValue.clear()method to set the empty value.- Specified by:
setValuein interfaceHasValue<AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,Set<T>>, Set<T>> - Specified by:
setValuein interfaceMultiSelect<MultiSelectListBox<T>,T> - Overrides:
setValuein classAbstractField<MultiSelectListBox<T>,Set<T>> - Parameters:
value- the new value to set, notnull- Throws:
NullPointerException- if value isnull
-
updateSelection
Description copied from interface:MultiSelectUpdates the selection by adding and removing the given items from it.If all the added items were already selected and the removed items were not selected, this is a NO-OP.
Duplicate items (in both add and remove sets) are ignored.
- Specified by:
updateSelectionin interfaceMultiSelect<MultiSelectListBox<T>,T> - Parameters:
addedItems- the items to add, notnullremovedItems- the items to remove, notnull
-
getSelectedItems
Returns an immutable set of the currently selected items. It is safe to invoke otherSelectionModelmethods while iterating over the set.There are no guarantees of the iteration order of the returned set of items.
- Specified by:
getSelectedItemsin interfaceMultiSelect<MultiSelectListBox<T>,T> - Returns:
- the items in the current selection, not
null
-
addSelectionListener
Description copied from interface:MultiSelectAdds a selection listener that will be called when the selection is changed either by the user or programmatically.- Specified by:
addSelectionListenerin interfaceMultiSelect<MultiSelectListBox<T>,T> - Parameters:
listener- the value change listener, notnull- Returns:
- a registration for the listener
-
getSelectionPreservationMode
Gets the selection preservation mode.- Returns:
- the selection preservation mode
- See Also:
-
setModelValue
Description copied from class:AbstractFieldUpdates the model value if the value has actually changed. Subclasses should call this method whenever the user has changed the value. A value change event is fired if the new value is different from the previous value according toAbstractField.valueEquals(Object, Object).If the value is from the client-side and this field is in readonly mode, then the new model value will be ignored.
AbstractField.setPresentationValue(Object)will be called with the previous model value so that the representation shown to the user can be reverted.See
AbstractFieldfor an overall description on the difference between model values and presentation values.- Overrides:
setModelValuein classAbstractField<MultiSelectListBox<T>,Set<T>> - Parameters:
newModelValue- the new internal value to usefromClient-trueif the new value originates from the client; otherwisefalse
-
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<MultiSelectListBox<T>,Set<T>> - Parameters:
value1- the first set of instancevalue2- the second set of instance- Returns:
trueif sets are equal in size and also the items; otherwisefalse
-