Class ItemCountChangeEvent<T extends com.vaadin.flow.component.Component>

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<T>
com.vaadin.flow.data.provider.ItemCountChangeEvent<T>
Type Parameters:
T - the event source type
All Implemented Interfaces:
Serializable

public class ItemCountChangeEvent<T extends com.vaadin.flow.component.Component> extends com.vaadin.flow.component.ComponentEvent<T>
Event describing the item count change for a component. The ItemCountChangeEvent will fired during the "before client response"-phase, so changes done during the server round trip will only receive one event. For example, this code will trigger only one event, although there are two methods called which cause the item count change:
 
 dataView.addItemCountChangeListener(listener);
 dataView.addItem(newItem);
 dataView.setFilter(filter);
 
 
See Also:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemCountChangeEvent(T source, int itemCount, boolean itemCountEstimated)
    Creates a new event using the given source and indicator whether the event originated from the client side or the server side.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the new item count for the component.
    boolean
    Returns whether the item count getItemCount() is an estimate or the exact count.

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

    getSource, isFromClient, unregisterListener

    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

    • ItemCountChangeEvent

      public ItemCountChangeEvent(T source, int itemCount, boolean itemCountEstimated)
      Creates a new event using the given source and indicator whether the event originated from the client side or the server side.
      Parameters:
      source - the source component
      itemCount - new items count
      itemCountEstimated - whether item count is an estimate
  • Method Details

    • getItemCount

      public int getItemCount()
      Get the new item count for the component.
      Returns:
      items count
    • isItemCountEstimated

      public boolean isItemCountEstimated()
      Returns whether the item count getItemCount() is an estimate or the exact count. An estimate is used when items are fetched lazily from the backend and the count callback has not been provided. See further details from LazyDataView.setItemCountEstimate(int).

      NOTE: this only applies for components that do lazy loading from the backend and implement HasLazyDataView.

      Returns:
      true when the count is an estimate, false when the count is exact