T - the type of the items in ComboBoxpublic class ComboBoxLazyDataView<T> extends AbstractLazyDataView<T>
component, dataProviderSupplier, NULL_IDENTIFIER_ERROR_MESSAGE, NULL_ITEM_ERROR_MESSAGE| Constructor and Description |
|---|
ComboBoxLazyDataView(DataCommunicator<T> dataCommunicator,
Component component)
Creates a new lazy data view for ComboBox and verifies the passed data
provider is compatible with this data view implementation.
|
| 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 in the
ComboBox's server-side.
|
Stream<T> |
getItems()
Gets the items available on the ComboBox's server-side.
|
void |
setItemCountCallback(CallbackDataProvider.CountCallback<T,String> callback)
Sets a callback that the combo box uses to get the exact item count in
the backend.
|
void |
setItemCountEstimate(int itemCountEstimate)
Sets the estimated item count for the component.
|
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.
|
getDataCommunicator, getItemCountEstimate, getItemCountEstimateIncrease, getSupportedDataProviderType, setItemCountEstimateIncreaseequals, getIdentifierProvider, refreshAll, refreshItem, setIdentifierProvider, verifyDataProviderTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrefreshAll, refreshItem, setIdentifierProviderpublic ComboBoxLazyDataView(DataCommunicator<T> dataCommunicator, Component component)
dataCommunicator - the data communicator of the componentcomponent - the ComboBoxpublic void setItemCountCallback(CallbackDataProvider.CountCallback<T,String> callback)
The given callback will be queried for the count instead of the data
provider DataProvider.size(Query) method when the component has a
distinct data provider set with
HasLazyDataView.setItems(BackEndDataProvider).
callback - the callback to use for determining item count in the backend,
not nullsetItemCountFromDataProvider(),
setItemCountUnknown()public void setItemCountFromDataProvider()
LazyDataViewDataProvider.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>setItemCountFromDataProvider in class AbstractLazyDataView<T>public void setItemCountEstimate(int itemCountEstimate)
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.
Calling this method will clear any previously set count callback
setItemCountCallback(CallbackDataProvider.CountCallback).
setItemCountEstimate in interface LazyDataView<T>setItemCountEstimate in class AbstractLazyDataView<T>itemCountEstimate - estimated item count of the backendLazyDataView.setItemCountUnknown(),
LazyDataView.setItemCountEstimateIncrease(int)public void setItemCountUnknown()
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.
Calling this method will clear any previously set count callback
setItemCountCallback(CallbackDataProvider.CountCallback).
setItemCountUnknown in interface LazyDataView<T>setItemCountUnknown in class AbstractLazyDataView<T>public 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.
Combo box fires ItemCountChangeEvent and notifies all the
listeners added by this method, if the items count changed, for instance,
due to fetching more items while scrolling with unknown item count.
ComboBox's client-side filter change won't fire
ItemCountChangeEvent, since it doesn't change the item count on
the server-side, but only makes it easier for users to search through the
items in the UI.
addItemCountChangeListener in interface DataView<T>addItemCountChangeListener in class AbstractDataView<T>listener - item count change listener to registerpublic T getItem(int index)
This method does not take into account the ComboBox client-side filtering, since it doesn't change the item count on the server-side, but only makes it easier for users to search through the items in the UI.
getItem in interface DataView<T>getItem in class AbstractLazyDataView<T>index - item index numberIndexOutOfBoundsException - requested index is outside of the data setCopyright © 2022. All rights reserved.