T - the type of the displayed itempublic interface HasItems<T> extends Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Modifier and Type | Method and Description |
|---|---|
DataProvider<T,?> |
getDataProvider()
Returns the source of data items used by this listing.
|
void |
setItems(Collection<T> items)
Sets the data items of this component provided as a collection.
|
default void |
setItems(Stream<T> streamOfItems)
Sets the data items of this listing provided as a stream.
|
default void |
setItems(T... items)
Sets the data items of this listing.
|
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesignaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedDataProvider<T,?> getDataProvider()
void setItems(Collection<T> items)
The provided items are wrapped into a ListDataProvider and this
instance is used as a data provider for the
#setDataProvider(DataProvider) method. It means that the items
collection can be accessed later on via
ListDataProvider.getItems():
HasDataProvider<String> listing = new CheckBoxGroup<>();
listing.setItems(Arrays.asList("a","b"));
...
Collection collection = ((ListDataProvider)listing.getDataProvider()).getItems();
The provided collection instance may be used as-is. Subsequent modification of the collection might cause inconsistent data to be shown in the component unless it is explicitly instructed to read the data again.
items - the data items to display, not nulldefault void setItems(T... items)
The provided items are wrapped into a ListDataProvider and this
instance is used as a data provider for the
#setDataProvider(DataProvider) method. It means that the items
collection can be accessed later on via
ListDataProvider.getItems():
HasDataProvider listing = new CheckBoxGroup<>();
listing.setItems("a","b");
...
Collection collection = ((ListDataProvider)listing.getDataProvider()).getItems();
items - the data items to displaysetItems(Collection)default void setItems(Stream<T> streamOfItems)
This is just a shorthand for setItems(Collection), that
collects objects in the stream to a list. Thus, using this method,
instead of its array and Collection variations, doesn't save any memory.
If you have a large data set to bind, using a lazy data provider is
recommended. See BackEndDataProvider for more info.
The provided items are wrapped into a ListDataProvider and this
instance is used as a data provider for the
#setDataProvider(DataProvider) method. It means that the items
collection can be accessed later on via
ListDataProvider.getItems():
HasDataProvider<String> listing = new CheckBoxGroup<>();
listing.setItems(Stream.of("a","b"));
...
Collection collection = ((ListDataProvider<String>)listing.getDataProvider()).getItems();
streamOfItems - the stream of data items to display, not nullsetItems(Collection)Copyright © 2022 Vaadin Ltd. All rights reserved.