T
- the type of datapublic abstract class AbstractLazyDataView<T> extends AbstractDataView<T> implements LazyDataView<T>
component, dataProviderSupplier, NULL_IDENTIFIER_ERROR_MESSAGE, NULL_ITEM_ERROR_MESSAGE
Constructor and Description |
---|
AbstractLazyDataView(DataCommunicator<T> dataCommunicator,
Component component)
Creates a new instance and verifies the passed data provider is
compatible with this data view implementation.
|
Modifier and Type | Method and Description |
---|---|
protected DataCommunicator<T> |
getDataCommunicator()
Returns the data communicator for the component and checks that the data
provider is of the correct type.
|
T |
getItem(int index)
Gets the item at the given index from the data available to the
component.
|
int |
getItemCountEstimate()
Gets the item count estimate.
|
int |
getItemCountEstimateIncrease()
Gets the item count estimate increase - how much the item count estimate
is increased once the previous item count estimate has been reached.
|
Stream<T> |
getItems()
Get the full data available to the component.
|
protected Class<?> |
getSupportedDataProviderType()
Returns supported
DataProvider type for this DataView . |
void |
setItemCountEstimate(int itemCountEstimate)
Sets the estimated item count for the component.
|
void |
setItemCountEstimateIncrease(int itemCountEstimateIncrease)
Sets how much the item count estimate is increased once the previous item
count estimate has been reached.
|
void |
setItemCountFromDataProvider()
Switches the component to get the exact item count from the data
provider's
DataProvider.size(Query) . |
void |
setItemCountUnknown()
Switches the component to automatically extend the number of items as the
previous end is almost reached.
|
addItemCountChangeListener, equals, getIdentifierProvider, refreshAll, refreshItem, setIdentifierProvider, verifyDataProviderType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addItemCountChangeListener, refreshAll, refreshItem, setIdentifierProvider
public AbstractLazyDataView(DataCommunicator<T> dataCommunicator, Component component)
dataCommunicator
- the data communicator of the componentcomponent
- the componentprotected DataCommunicator<T> getDataCommunicator()
public T getItem(int index)
Calling this method with an index that is not currently active in the
component will cause a query to the backend, so do not call this method
carelessly. Use
UI.beforeClientResponse(Component, SerializableConsumer)
to access items that will be fetched later on.
getItem
in interface DataView<T>
index
- the index of the item to getIndexOutOfBoundsException
- requested index is outside of the filtered and sorted data
setpublic Stream<T> getItems()
DataView
protected Class<?> getSupportedDataProviderType()
AbstractDataView
DataProvider
type for this DataView
.getSupportedDataProviderType
in class AbstractDataView<T>
public void setItemCountEstimate(int itemCountEstimate)
LazyDataView
The given estimate is discarded if it is less than the currently shown
range or if the actual number of items has been determined. The estimate
shouldn't be less than two pages (see setPageSize(int)
in the
component) or it causes unnecessary backend requests.
setItemCountEstimate
in interface LazyDataView<T>
itemCountEstimate
- estimated item count of the backendLazyDataView.setItemCountUnknown()
,
LazyDataView.setItemCountEstimateIncrease(int)
public int getItemCountEstimate()
LazyDataView
getItemCountEstimate
in interface LazyDataView<T>
LazyDataView.setItemCountEstimate(int)
public void setItemCountEstimateIncrease(int itemCountEstimateIncrease)
LazyDataView
As an example, with an estimate of 1000
and an increase of
500
, when scrolling down the item count will be:
1000, 1500, 2000, 2500...
until the backend runs out of items.
NOTE: the given increase should not be less than the
setPageSize(int)
set in the component, or there will be
unnecessary backend requests.
setItemCountEstimateIncrease
in interface LazyDataView<T>
itemCountEstimateIncrease
- how much the item count estimate is increasedLazyDataView.setItemCountEstimate(int)
public int getItemCountEstimateIncrease()
LazyDataView
getItemCountEstimateIncrease
in interface LazyDataView<T>
LazyDataView.setItemCountEstimateIncrease(int)
public void setItemCountFromDataProvider()
LazyDataView
DataProvider.size(Query)
. Use this when it is cheap to
get the exact item count and it is desired that the user sees the "full
scrollbar size".setItemCountFromDataProvider
in interface LazyDataView<T>
public void setItemCountUnknown()
LazyDataView
The default initial item count and how much the item count is increased
depends on the component. These values can be customized with
LazyDataView.setItemCountEstimate(int)
and
LazyDataView.setItemCountEstimateIncrease(int)
when the backend has a lot of
items and faster scrolling down is desired.
setItemCountUnknown
in interface LazyDataView<T>
Copyright © 2021. All rights reserved.