T
- data typepublic interface DataView<T> extends Serializable
Modifier and Type | Method and Description |
---|---|
Registration |
addItemCountChangeListener(ComponentEventListener<ItemCountChangeEvent<?>> listener)
Add an item count change listener that is fired when the item count
changes.
|
T |
getItem(int index)
Gets the item at the given index from the data available to the
component.
|
Stream<T> |
getItems()
Get the full data available to the component.
|
void |
refreshItem(T item)
Notifies the component that the item has been updated and thus should be
refreshed.
|
void |
setIdentifierProvider(IdentifierProvider<T> identifierProvider)
Sets an identifier provider, which returns an identifier for the given
item.
|
T getItem(int index)
index
- item index numberIndexOutOfBoundsException
- requested index is outside of the filtered and sorted data
setStream<T> getItems()
void refreshItem(T item)
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)
.
item
- item containing updated statesetIdentifierProvider(IdentifierProvider)
Registration addItemCountChangeListener(ComponentEventListener<ItemCountChangeEvent<?>> listener)
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
.
listener
- item count change listener to registervoid setIdentifierProvider(IdentifierProvider<T> identifierProvider)
dataView.setIdentifiedProvider(Item::getId);
.identifierProvider
- function that returns the non-null identifier for a given itemCopyright © 2020. All rights reserved.