T
- the type of the items contained by this componentpublic class MultiSelectListBox<T> extends ListBoxBase<MultiSelectListBox<T>,T,Set<T>> implements MultiSelect<MultiSelectListBox<T>,T>
vaadin-list-box
element with
multi-selection.ListBox
,
Serialized FormAbstractField.ComponentValueChangeEvent<C extends Component,V>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
HasItemsAndComponents.ItemComponent<T>
Constructor and Description |
---|
MultiSelectListBox()
Creates a new list box component with multi-selection.
|
Modifier and Type | Method and Description |
---|---|
Registration |
addSelectionListener(MultiSelectionListener<MultiSelectListBox<T>,T> listener)
Adds a selection listener that will be called when the selection is
changed either by the user or programmatically.
|
Set<T> |
getSelectedItems()
Returns an immutable set of the currently selected items.
|
void |
setValue(Set<T> value)
Sets the value of this component.
|
void |
updateSelection(Set<T> addedItems,
Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
|
getDataProvider, getItemEnabledProvider, getItemRenderer, onAttach, onDetach, onEnabledStateChanged, setDataProvider, setItemEnabledProvider, setRenderer, setRequiredIndicatorVisible
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deselect, deselect, deselectAll, getEmptyValue, getValue, isSelected, select, select
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
addValueChangeListener, clear, getOptionalValue, isEmpty
isEnabled, setEnabled
getElement
addComponents, getItemPosition, prependComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
setItems
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
addAttachListener
addDetachListener
public MultiSelectListBox()
public void setValue(Set<T> value)
The component doesn't accept null
values. The value of multi
select list box without any selected items is an empty set. You can use
the HasValue.clear()
method to set the empty value.
setValue
in interface HasValue<AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,Set<T>>,Set<T>>
setValue
in interface MultiSelect<MultiSelectListBox<T>,T>
setValue
in class AbstractField<MultiSelectListBox<T>,Set<T>>
value
- the new value to set, not null
NullPointerException
- if value is null
public void updateSelection(Set<T> addedItems, Set<T> removedItems)
MultiSelect
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.
updateSelection
in interface MultiSelect<MultiSelectListBox<T>,T>
addedItems
- the items to add, not null
removedItems
- the items to remove, not null
public Set<T> getSelectedItems()
SelectionModel
methods while iterating over the set.
There are no guarantees of the iteration order of the returned set of items.
getSelectedItems
in interface MultiSelect<MultiSelectListBox<T>,T>
null
public Registration addSelectionListener(MultiSelectionListener<MultiSelectListBox<T>,T> listener)
MultiSelect
addSelectionListener
in interface MultiSelect<MultiSelectListBox<T>,T>
listener
- the value change listener, not null
Copyright © 2025. All rights reserved.