Interface DataView<T>

Type Parameters:
T - data type
All Superinterfaces:
Serializable
All Known Subinterfaces:
LazyDataView<T>, ListDataView<T,V>
All Known Implementing Classes:
AbstractDataView, AbstractLazyDataView, AbstractListDataView, CheckboxGroupDataView, CheckboxGroupListDataView, ComboBoxDataView, ComboBoxLazyDataView, ComboBoxListDataView, GridDataView, GridLazyDataView, GridListDataView, ListBoxDataView, ListBoxListDataView, RadioButtonGroupDataView, RadioButtonGroupListDataView, SelectDataView, SelectListDataView

public interface DataView<T> extends Serializable
Base view interface for getting information on current data set of a Component.
Since:
  • Method Details

    • getItem

      T getItem(int index)
      Gets the item at the given index from the data available to the component. Data is filtered and sorted the same way as in the component.
      Parameters:
      index - item index number
      Returns:
      item on index
      Throws:
      IndexOutOfBoundsException - requested index is outside of the filtered and sorted data set
    • getItems

      Stream<T> getItems()
      Get the full data available to the component. Data is filtered and sorted the same way as in the component.
      Returns:
      filtered and sorted data set
    • refreshItem

      void refreshItem(T item)
      Notifies the component that the item has been updated and thus should be refreshed.

      For this to work properly, the item must either implement Object.equals(Object) and Object.hashCode() to consider both the old and the new item instances to be equal, or alternatively use the setIdentifierProvider(IdentifierProvider) to set an appropriate item's identifier.

      This method delegates the update to DataProvider.refreshItem(Object).

      Parameters:
      item - item containing updated state
      See Also:
    • refreshAll

      void refreshAll()
      Notifies the component that all the items should be refreshed.
    • addItemCountChangeListener

      Registration addItemCountChangeListener(ComponentEventListener<ItemCountChangeEvent<?>> listener)
      Add an item count change listener that is fired when the item count changes. This can happen for instance when filtering the items.

      Item count change listener is bound to the component and will be retained even if the data changes by setting of a new items or DataProvider to component.

      NOTE: when the component supports lazy loading (implements HasLazyDataView) and a count callback has not been provided, an estimate of the item count is used and increased until the actual count has been reached. When the estimate is used, the event is fired with the ItemCountChangeEvent.isItemCountEstimated() returning true.

      Parameters:
      listener - item count change listener to register
      Returns:
      registration for removing the listener
    • setIdentifierProvider

      void setIdentifierProvider(IdentifierProvider<T> identifierProvider)
      Sets an identifier provider, which returns an identifier for the given item. The identifier is used for comparing the equality of items. Usage example: dataView.setIdentifiedProvider(Item::getId);.
      Parameters:
      identifierProvider - function that returns the non-null identifier for a given item