Class AbstractDataCountEvent

java.lang.Object
java.util.EventObject
com.vaadin.flow.server.data.AbstractDataCountEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DataCountEndedEvent, DataCountFailedEvent, DataCountStartedEvent

public abstract class AbstractDataCountEvent extends EventObject
Details shared by the events fired around a count query issued to a data provider, that is a query asking how many items a level holds rather than for the items themselves.

A flat component issues one count query per level reload. A hierarchical component issues one per expanded parent, so several count events for one component within a single request is the signature of an expensive hierarchy.

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 DataCountStartedEvent, DataCountFailedEvent or DataCountEndedEvent instead.

Since:
25.3
See Also:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractDataCountEvent(UI ui, Component component, boolean filtered)
    Creates a new count event.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the component whose data is being counted, so that an observer can attribute the query to a Grid, ComboBox or TreeGrid rather than only to the request.
    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 counting matches for what the user typed from one counting 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

    • AbstractDataCountEvent

      protected AbstractDataCountEvent(UI ui, Component component, boolean filtered)
      Creates a new count event.
      Parameters:
      ui - the UI the counting component belongs to, not null
      component - the component whose data is being counted, or null if it could not be resolved
      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 counted, 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
    • isFiltered

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