com.vaadin.data.
Interface HasItems<T>
-
Type Parameters:
T
- the type of the displayed itemAll Superinterfaces:
ClientConnector
,Component
,Connector
,Serializable
,Sizeable
All Known Subinterfaces:
HasDataProvider<T>
,HasFilterableDataProvider<T,F>
,HasHierarchicalDataProvider<T>
All Known Implementing Classes:
AbstractListing
,AbstractMultiSelect
,AbstractSingleSelect
,CheckBoxGroup
,ComboBox
,Grid
,ListSelect
,NativeSelect
,RadioButtonGroup
,Tree
,TreeGrid
,TwinColSelect
public interface HasItems<T> extends Component
A component that displays a collection of items.
Since:
8.0
Author:
Vaadin Ltd
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Method Summary
All Methods Modifier and Type Method 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.
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
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, writeDesign
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Method Detail
-
getDataProvider
DataProvider<T,?> getDataProvider()
Returns the source of data items used by this listing.
Returns:
the data provider, not null
-
setItems
void setItems(Collection<T> items)
Sets the data items of this component provided as a collection.
The provided items are wrapped into a
ListDataProvider
and this instance is used as a data provider for theHasDataProvider.setDataProvider(DataProvider)
method. It means that the items collection can be accessed later on viaListDataProvider.getItems()
:HasDataProvider<String> listing = new CheckBoxGroup<>(); listing.setItems(Arrays.asList("a","b")); ... Collection<String> collection = ((ListDataProvider<String>)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.
Parameters:
items
- the data items to display, not null
-
setItems
default void setItems(T... items)
Sets the data items of this listing.
The provided items are wrapped into a
ListDataProvider
and this instance is used as a data provider for theHasDataProvider.setDataProvider(DataProvider)
method. It means that the items collection can be accessed later on viaListDataProvider.getItems()
:HasDataProvider<String> listing = new CheckBoxGroup<>(); listing.setItems("a","b"); ... Collection<String> collection = ((ListDataProvider<String>)listing.getDataProvider()).getItems();
Parameters:
items
- the data items to displaySee Also:
-
setItems
default void setItems(Stream<T> streamOfItems)
Sets the data items of this listing provided as a stream.
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. SeeBackEndDataProvider
for more info.The provided items are wrapped into a
ListDataProvider
and this instance is used as a data provider for theHasDataProvider.setDataProvider(DataProvider)
method. It means that the items collection can be accessed later on viaListDataProvider.getItems()
:HasDataProvider<String> listing = new CheckBoxGroup<>(); listing.setItems(Stream.of("a","b")); ... Collection<String> collection = ((ListDataProvider<String>)listing.getDataProvider()).getItems();
Parameters:
streamOfItems
- the stream of data items to display, notnull
See Also:
-
-