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

    • Method Detail

      • 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
      • 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