Class AbstractDataFetchEvent

java.lang.Object
java.util.EventObject
com.vaadin.flow.server.data.AbstractDataFetchEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DataFetchEndedEvent, DataFetchFailedEvent, DataFetchStartedEvent

public abstract class AbstractDataFetchEvent extends EventObject
Details shared by the events fired around a fetch query issued to a data provider, that is a query loading one page of items.

getOffset() and getLimit() say what was asked for; DataFetchEndedEvent.getRowsReturned() says what came back. A component that repeatedly asks for far more than it renders, or a data provider that returns short pages, both show up as a gap between the two.

The events carry only plain values and the resolved Component, never the query or the data provider, so that observers cannot retain or mutate loading state.

This type cannot be listened for. The service event bus dispatches by exact runtime type, so a listener registered for this class is never notified; register for DataFetchStartedEvent, DataFetchFailedEvent or DataFetchEndedEvent instead.

Since:
25.3
See Also:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractDataFetchEvent(UI ui, Component component, int offset, int limit, boolean filtered)
    Creates a new fetch event.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the component whose data is being fetched, so that an observer can attribute the query to a Grid, ComboBox or TreeGrid rather than only to the request.
    int
    Gets the number of items requested.
    int
    Gets the index of the first item requested.
    Gets the UI from which this event originates.
    Gets the UI from which this event originates.
    boolean
    Tells whether a filter was set on the query, which distinguishes a combo box loading matches for what the user typed from one loading the whole data set.

    Methods inherited from class java.util.EventObject

    toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AbstractDataFetchEvent

      protected AbstractDataFetchEvent(UI ui, Component component, int offset, int limit, boolean filtered)
      Creates a new fetch event.
      Parameters:
      ui - the UI the fetching component belongs to, not null
      component - the component whose data is being fetched, or null if it could not be resolved
      offset - the index of the first item requested
      limit - the number of items requested
      filtered - whether a filter was set on the query
  • Method Details

    • getSource

      public UI getSource()
      Gets the UI from which this event originates.
      Overrides:
      getSource in class EventObject
      Returns:
      the UI, never null
    • getUI

      public UI getUI()
      Gets the UI from which this event originates.
      Returns:
      the UI, never null
    • getComponent

      public Optional<Component> getComponent()
      Gets the component whose data is being fetched, so that an observer can attribute the query to a Grid, ComboBox or TreeGrid rather than only to the request.

      Empty when the component could not be resolved from the state node, for example when the data communicator is driven by a bare element.

      Returns:
      the component, or an empty optional
    • getOffset

      public int getOffset()
      Gets the index of the first item requested.
      Returns:
      the offset, never negative
    • getLimit

      public int getLimit()
      Gets the number of items requested. The data provider may return fewer; compare against DataFetchEndedEvent.getRowsReturned().
      Returns:
      the limit, never negative
    • isFiltered

      public boolean isFiltered()
      Tells whether a filter was set on the query, which distinguishes a combo box loading matches for what the user typed from one loading the whole data set.
      Returns:
      true if the query carried a filter