Interface HasLazyDataView<T,F,V extends LazyDataView<T>>

Type Parameters:
T - item type
F - filter type
V - DataView type
All Superinterfaces:
Serializable
All Known Implementing Classes:
ComboBox, ComboBoxBase, CrudGrid, Grid, GridPro, MultiSelectComboBox, TreeGrid

public interface HasLazyDataView<T,F,V extends LazyDataView<T>> extends Serializable
Interface that defines methods for fetching items lazily from a backend. The API will return a LazyDataView.
Since:
  • Method Details

    • setItems

      default V setItems(CallbackDataProvider.FetchCallback<T,F> fetchCallback)
      Supply items lazily with a callback from a backend. The component will automatically fetch more items and adjust its size until the backend runs out of items. Usage example without component provided filter:

      component.setItems(query -> orderService.getOrders(query.getOffset(), query.getLimit());

      If the component supports filtering, it can be fetched with query.getFilter().

      The returned data view object can be used for further configuration, or later on fetched with getLazyDataView(). For using in-memory data, like Collection, use HasListDataView.setItems(Collection) instead.

      Parameters:
      fetchCallback - function that returns a stream of items from the backend based on the offset, limit and an optional filter provided by the query object
      Returns:
      LazyDataView instance for further configuration
    • setItems

      default V setItems(CallbackDataProvider.FetchCallback<T,F> fetchCallback, CallbackDataProvider.CountCallback<T,F> countCallback)
      Supply items lazily with callbacks: the first one fetches the items based on offset, limit and an optional filter, the second provides the exact count of items in the backend. Use this in case getting the count is cheap and the user benefits from the component showing immediately the exact size. Usage example without component provided filter:

      component.setItems( query -> orderService.getOrders(query.getOffset, query.getLimit()), query -> orderService.getSize());

      If the component supports filtering, it can be fetched with query.getFilter().

      The returned data view object can be used for further configuration, or later on fetched with getLazyDataView(). For using in-memory data, like Collection, use HasListDataView.setItems(Collection) instead.

      Parameters:
      fetchCallback - function that returns a stream of items from the back end for a query
      countCallback - function that return the number of items in the back end for a query
      Returns:
      LazyDataView instance for further configuration
    • setItems

      V setItems(BackEndDataProvider<T,F> dataProvider)
      Supply items with a BackEndDataProvider that lazy loads items from a backend. Note that component will query the data provider for the item count. In case that is not desired for performance reasons, use setItems(CallbackDataProvider.FetchCallback) instead.

      The returned data view object can be used for further configuration, or later on fetched with getLazyDataView(). For using in-memory data, like Collection, use HasListDataView.setItems(Collection) instead.

      Parameters:
      dataProvider - BackEndDataProvider instance
      Returns:
      LazyDataView instance for further configuration
    • getLazyDataView

      V getLazyDataView()
      Get the LazyDataView for the component that allows access to the items in the component. Throws an exception if the items are not provided lazily and another data view type should be used, like ListDataView.
      Returns:
      LazyDataView instance
      Throws:
      IllegalStateException - when lazy data view is not applicable