Interface DataProvider<T>

Type Parameters:
T - the data item type
All Known Subinterfaces:
HierarchicalDataProvider<T>
All Known Implementing Classes:
AbstractDataProvider, CallbackDataProvider, ListDataProvider

public interface DataProvider<T>
Core interface for providing data to components with pagination, sorting, and filtering.

DataProvider abstracts data access so that components (grids, lists, tables, trees) can load data on demand without knowing the underlying data source. Implementations handle in-memory collections, database queries, REST API calls, or any other source.

Built-in implementations:

Usage with a grid component:


 DataProvider<User> provider = new CallbackDataProvider<>(
     query -> userService.findAll(query),
     query -> userService.count(query)
 );
 grid.setDataProvider(provider);
 
Since:
2.1
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Method Details

    • fetch

      DataResult<T> fetch(Query query)
      Fetches a page of data matching the query parameters.
      Parameters:
      query - the query with offset, limit, sorts, and filters
      Returns:
      the result containing items and total count
    • size

      int size(Query query)
      Returns the total number of items matching the query's filters.
      Parameters:
      query - the query (only filters are relevant; offset/limit are ignored)
      Returns:
      the total count of matching items
    • addDataChangeListener

      void addDataChangeListener(DataChangeListener listener)
      Registers a listener to be notified when the data changes.
      Parameters:
      listener - the listener to add
    • removeDataChangeListener

      void removeDataChangeListener(DataChangeListener listener)
      Removes a previously registered data change listener.
      Parameters:
      listener - the listener to remove
    • refresh

      void refresh()
      Notifies all registered listeners that the data has changed.

      Call this after modifying the underlying data source to trigger UI components to refresh their display.