Package com.oorian.data
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:
ListDataProvider— wraps an in-memoryListCallbackDataProvider— delegates to user-provided callbacks for lazy loading
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 Summary
Modifier and TypeMethodDescriptionvoidaddDataChangeListener(DataChangeListener listener) Registers a listener to be notified when the data changes.Fetches a page of data matching the query parameters.voidrefresh()Notifies all registered listeners that the data has changed.voidremoveDataChangeListener(DataChangeListener listener) Removes a previously registered data change listener.intReturns the total number of items matching the query's filters.
-
Method Details
-
fetch
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
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
Registers a listener to be notified when the data changes.- Parameters:
listener- the listener to add
-
removeDataChangeListener
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.
-