Package com.vaadin.flow.data.provider
Interface HasDataView<T,F,V extends DataView<T>>
- Type Parameters:
T- data typeF- filter typeV- DataView type
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
CheckboxGroup,ComboBox,ComboBoxBase,CrudGrid,Grid,GridPro,ListBox,ListBoxBase,MultiSelectComboBox,MultiSelectListBox,RadioButtonGroup,Select,TreeGrid
An interface for components that get items from the generic data provider
types
DataProvider and InMemoryDataProvider. The methods
return a DataView which has the generic API for getting information
on the items.-
Method Summary
Modifier and TypeMethodDescriptiondefault VBinds a signal containing a list of item signals to this component, enabling fine-grained reactive updates.Get the DataView for the component.setItems(DataProvider<T, F> dataProvider) Set a generic data provider for the component to use and returns the baseDataViewthat provides API to get information on the items.setItems(InMemoryDataProvider<T> dataProvider) Sets an in-memory data provider for the component to use
-
Method Details
-
setItems
Set a generic data provider for the component to use and returns the baseDataViewthat provides API to get information on the items.This method should be used only when the data provider type is not either
ListDataProviderorBackEndDataProvider.- Parameters:
dataProvider- DataProvider instance to use, notnull- Returns:
- DataView providing information on the data
-
setItems
Sets an in-memory data provider for the component to useNote! Using a
ListDataProviderinstead of aInMemoryDataProvideris recommended to get access toListDataViewAPI by usingHasListDataView.setItems(ListDataProvider).- Parameters:
dataProvider- InMemoryDataProvider to use, notnull- Returns:
- DataView providing information on the data
-
getGenericDataView
V getGenericDataView()Get the DataView for the component.The returned DataView only contains a minimal common API. Use of
HasListDataView.getListDataView()orHasLazyDataView.getLazyDataView()should be used for more targeted helper features- Returns:
- DataView instance
-
bindItems
Binds a signal containing a list of item signals to this component, enabling fine-grained reactive updates. This method establishes a reactive binding where:- Changes to the outer signal (list structure changes such as adding or
removing items) trigger
DataView.refreshAll() - Changes to any inner signal (individual item value changes) trigger
DataView.refreshItem(Object)for that specific item
The binding is automatically managed based on the component's lifecycle. When the component is attached, the effects are activated; when detached, they are deactivated.
Example usage:
ListSignal<String> items = new ListSignal<>(); items.insertLast("Item 1"); items.insertLast("Item 2"); component.bindItems(items); // Structural change - triggers refreshAll() items.insertLast("Item 3"); // Item value change - triggers refreshItem() items.peek().get(0).set("Updated Item 1");- Parameters:
itemsSignal- the signal containing a list of item signals (e.g., ListSignal), notnull- Returns:
- the DataView providing access to the items
- Throws:
IllegalArgumentException- if this is not a Component instanceBindingActiveException- if there is already an active items binding
- Changes to the outer signal (list structure changes such as adding or
removing items) trigger
-