Class SelectionPreservationHandler<T>

java.lang.Object
com.vaadin.flow.component.shared.SelectionPreservationHandler<T>
All Implemented Interfaces:
Serializable

public abstract class SelectionPreservationHandler<T> extends Object implements Serializable
Abstract class that handles selection when DataProvider.refreshAll() is called.

Uses SelectionPreservationMode to switch between the selection preservation modes.

Author:
Vaadin Ltd.
See Also:
  • Constructor Details

    • SelectionPreservationHandler

      public SelectionPreservationHandler(SelectionPreservationMode selectionPreservationMode)
      Constructor taking in the initial selection preservation mode.
      Parameters:
      selectionPreservationMode - the selection preservation mode, not null
  • Method Details

    • setSelectionPreservationMode

      public final void setSelectionPreservationMode(SelectionPreservationMode selectionPreservationMode)
      Sets the selection preservation mode. Determines what happens with the selection when DataProvider.refreshAll() is called.
      Parameters:
      selectionPreservationMode - the selection preservation mode to switch to, not null
      See Also:
    • getSelectionPreservationMode

      public final SelectionPreservationMode getSelectionPreservationMode()
      Gets the selection preservation mode.
      Returns:
      the selection preservation mode
      See Also:
    • handleDataChange

      public final void handleDataChange(com.vaadin.flow.data.provider.DataChangeEvent<T> dataChangeEvent)
      Handles data change based on the current selection preservation mode.
      Parameters:
      dataChangeEvent - the data change event
      See Also:
    • onPreserveAll

      public abstract void onPreserveAll(com.vaadin.flow.data.provider.DataChangeEvent<T> dataChangeEvent)
      Preserves all selected items when DataProvider.refreshAll() is called.
      Parameters:
      dataChangeEvent - the data change event
    • onPreserveExisting

      public abstract void onPreserveExisting(com.vaadin.flow.data.provider.DataChangeEvent<T> dataChangeEvent)
      Preserves the selected items that still exist after DataProvider.refreshAll() is called.
      Parameters:
      dataChangeEvent - the data change event
    • onDiscard

      public abstract void onDiscard(com.vaadin.flow.data.provider.DataChangeEvent<T> dataChangeEvent)
      Clears selection when DataProvider.refreshAll() is called.
      Parameters:
      dataChangeEvent - the data change event