Class SingleSelectionEvent<C extends com.vaadin.flow.component.Component,T>

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<C>
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,T>
com.vaadin.flow.data.selection.SingleSelectionEvent<C,T>
Type Parameters:
C - the selection component type
T - the type of the selected item
All Implemented Interfaces:
com.vaadin.flow.component.HasValue.ValueChangeEvent<T>, SelectionEvent<C,T>, Serializable

public class SingleSelectionEvent<C extends com.vaadin.flow.component.Component,T> extends com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,T> implements SelectionEvent<C,T>
Fired when the selection changes in a listing component.
Since:
1.0.
Author:
Vaadin Ltd
See Also:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    SingleSelectionEvent(C listing, SingleSelect<C,T> source, T oldSelection, boolean userOriginated)
    Creates a new selection change event in a component.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets all the currently selected items.
    Get first selected data item.
    Returns an optional of the item that was selected, or an empty optional if a previously selected item was deselected.
    The listing component on which the Event initially occurred.

    Methods inherited from class com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent

    getHasValue, getOldValue, getValue, toString

    Methods inherited from class com.vaadin.flow.component.ComponentEvent

    isFromClient, unregisterListener

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.HasValue.ValueChangeEvent

    isFromClient

    Methods inherited from interface com.vaadin.flow.data.selection.SelectionEvent

    isFromClient
  • Constructor Details

    • SingleSelectionEvent

      public SingleSelectionEvent(C listing, SingleSelect<C,T> source, T oldSelection, boolean userOriginated)
      Creates a new selection change event in a component.
      Parameters:
      listing - the listing component where the event originated
      source - the single select source
      oldSelection - the item that was previously selected
      userOriginated - true if this event originates from the client, false otherwise.
  • Method Details

    • getSelectedItem

      public Optional<T> getSelectedItem()
      Returns an optional of the item that was selected, or an empty optional if a previously selected item was deselected.
      Returns:
      the selected item or an empty optional if deselected
      See Also:
    • getSource

      public C getSource()
      The listing component on which the Event initially occurred.
      Specified by:
      getSource in interface SelectionEvent<C extends com.vaadin.flow.component.Component,T>
      Overrides:
      getSource in class com.vaadin.flow.component.ComponentEvent<C extends com.vaadin.flow.component.Component>
      Returns:
      The listing component on which the Event initially occurred.
    • getFirstSelectedItem

      public Optional<T> getFirstSelectedItem()
      Description copied from interface: SelectionEvent
      Get first selected data item.

      This is the same as getSelectedItem() in case of single selection.

      Specified by:
      getFirstSelectedItem in interface SelectionEvent<C extends com.vaadin.flow.component.Component,T>
      Returns:
      the first selected item.
    • getAllSelectedItems

      public Set<T> getAllSelectedItems()
      Description copied from interface: SelectionEvent
      Gets all the currently selected items.

      This method applies more to multiselection - for single select it returns either an empty set or a set containing the only selected item.

      Specified by:
      getAllSelectedItems in interface SelectionEvent<C extends com.vaadin.flow.component.Component,T>
      Returns:
      return all the selected items, if any, never null