Class MultiSelectListBox<T>

  • Type Parameters:
    T - the type of the items contained by this component
    All Implemented Interfaces:
    com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,​Set<T>>,​Set<T>>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,​Set<T>>,​Set<T>>, HasTooltip, com.vaadin.flow.data.binder.HasItemComponents<T>, com.vaadin.flow.data.provider.HasDataView<T,​Void,​ListBoxDataView<T>>, com.vaadin.flow.data.provider.HasListDataView<T,​ListBoxListDataView<T>>, com.vaadin.flow.data.selection.MultiSelect<MultiSelectListBox<T>,​T>, Serializable

    public class MultiSelectListBox<T>
    extends ListBoxBase<MultiSelectListBox<T>,​T,​Set<T>>
    implements com.vaadin.flow.data.selection.MultiSelect<MultiSelectListBox<T>,​T>
    Server-side component for the vaadin-list-box element with multi-selection.
    Author:
    Vaadin Ltd
    See Also:
    ListBox, Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField

        com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,​V extends Object>
      • Nested classes/interfaces inherited from interface com.vaadin.flow.data.binder.HasItemComponents

        com.vaadin.flow.data.binder.HasItemComponents.ItemComponent<T extends Object>
      • Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

        com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiSelectListBox()
      Creates a new list box component with multi-selection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.vaadin.flow.shared.Registration addSelectionListener​(com.vaadin.flow.data.selection.MultiSelectionListener<MultiSelectListBox<T>,​T> listener)  
      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)  
      protected boolean valueEquals​(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.AbstractSinglePropertyField

        getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
      • Methods inherited from class com.vaadin.flow.component.AbstractField

        addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue
      • Methods inherited from class com.vaadin.flow.component.Component

        addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, scrollIntoView, set, setElement, setId, setVisible
      • Methods inherited from interface com.vaadin.flow.component.AttachNotifier

        addAttachListener
      • Methods inherited from interface com.vaadin.flow.component.DetachNotifier

        addDetachListener
      • Methods inherited from interface com.vaadin.flow.component.HasComponents

        add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll
      • Methods inherited from interface com.vaadin.flow.component.HasElement

        getElement
      • Methods inherited from interface com.vaadin.flow.component.HasEnabled

        isEnabled, setEnabled
      • Methods inherited from interface com.vaadin.flow.data.binder.HasItemComponents

        addComponents, getItemPosition, prependComponents
      • Methods inherited from interface com.vaadin.flow.data.provider.HasListDataView

        setItems, setItems
      • Methods 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, setWidthFull
      • Methods inherited from interface com.vaadin.flow.component.HasStyle

        addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
      • Methods inherited from interface com.vaadin.flow.component.HasValue

        addValueChangeListener, clear, getOptionalValue, isEmpty
      • Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

        isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
      • Methods inherited from interface com.vaadin.flow.data.selection.MultiSelect

        deselect, deselect, deselectAll, getEmptyValue, getValue, isSelected, select, select
    • Constructor Detail

      • MultiSelectListBox

        public MultiSelectListBox()
        Creates a new list box component with multi-selection.
    • Method Detail

      • setValue

        public void setValue​(Set<T> value)
        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 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.

        Specified by:
        setValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,​Set<T>>,​Set<T>>
        Specified by:
        setValue in interface com.vaadin.flow.data.selection.MultiSelect<MultiSelectListBox<T>,​T>
        Overrides:
        setValue in class com.vaadin.flow.component.AbstractField<MultiSelectListBox<T>,​Set<T>>
        Parameters:
        value - the new value to set, not null
        Throws:
        NullPointerException - if value is null
      • updateSelection

        public void updateSelection​(Set<T> addedItems,
                                    Set<T> removedItems)
        Specified by:
        updateSelection in interface com.vaadin.flow.data.selection.MultiSelect<MultiSelectListBox<T>,​T>
      • getSelectedItems

        public Set<T> getSelectedItems()
        Returns an immutable set of the currently selected items. It is safe to invoke other SelectionModel methods while iterating over the set.

        There are no guarantees of the iteration order of the returned set of items.

        Specified by:
        getSelectedItems in interface com.vaadin.flow.data.selection.MultiSelect<MultiSelectListBox<T>,​T>
        Returns:
        the items in the current selection, not null
      • addSelectionListener

        public com.vaadin.flow.shared.Registration addSelectionListener​(com.vaadin.flow.data.selection.MultiSelectionListener<MultiSelectListBox<T>,​T> listener)
        Specified by:
        addSelectionListener in interface com.vaadin.flow.data.selection.MultiSelect<MultiSelectListBox<T>,​T>
      • valueEquals

        protected boolean valueEquals​(Set<T> value1,
                                      Set<T> value2)
        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 when AbstractField.setValue(Object) or AbstractField.setModelValue(Object, boolean) is called. Subclasses can override this method to define an alternative comparison method instead of Object.equals(Object).
        Overrides:
        valueEquals in class com.vaadin.flow.component.AbstractField<MultiSelectListBox<T>,​Set<T>>
        Parameters:
        value1 - the first set of instance
        value2 - the second set of instance
        Returns:
        true if sets are equal in size and also the items; otherwise false