com.vaadin.flow.data.provider.
Class AbstractComponentDataGenerator<T>
Type Parameters:
T
- the data type
All Implemented Interfaces:
Direct Known Subclasses:
Abstract class used as base for DataGenerators that need to manage the lifecycle of components, according to what items are requested or destroyed.
Since:
1.0.
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Component
createComponent
(T item) Creates a new component based on the provided item.
void
Informs the
DataGenerator
that all data has been dropped.void
destroyData
(T item) Informs the
DataGenerator
that the given data item has been dropped and is no longer needed.protected abstract Element
Gets the element where the generated components will be attached to.
protected abstract String
getItemKey
(T item) Gets a unique key for a given item.
protected Component
getRenderedComponent
(String itemKey) void
refreshData
(T item) Informs the
DataGenerator
that a data object has been updated.protected void
registerRenderedComponent
(String itemKey, Component component) Appends the component to the container and registers it for future use during the lifecycle of the generator.
protected Component
updateComponent
(Component currentComponent, T item) Updates an existing component after the item has been updated.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.data.provider.DataGenerator
generateData
-
Constructor Details
-
AbstractComponentDataGenerator
public AbstractComponentDataGenerator()
-
-
Method Details
-
refreshData
Description copied from interface:
DataGenerator
Informs the
DataGenerator
that a data object has been updated. This method should update any unneeded information stored for given item.Specified by:
refreshData
in interfaceDataGenerator<T>
Parameters:
item
- the updated item -
destroyData
Description copied from interface:
DataGenerator
Informs the
DataGenerator
that the given data item has been dropped and is no longer needed. This method should clean up any unneeded information stored for this item.Specified by:
destroyData
in interfaceDataGenerator<T>
Parameters:
item
- the dropped data item -
destroyAllData
public void destroyAllData()Description copied from interface:
DataGenerator
Informs the
DataGenerator
that all data has been dropped. This method should clean up any unneeded information stored for items.Specified by:
destroyAllData
in interfaceDataGenerator<T>
-
getContainer
Gets the element where the generated components will be attached to.
Returns:
the container
-
createComponent
Creates a new component based on the provided item.
Parameters:
item
- the data item, possiblynull
Returns:
a
Component
which represents the provided item -
updateComponent
Updates an existing component after the item has been updated. By default, it creates a new component instance via
createComponent(Object)
.Parameters:
currentComponent
- the current component used to represent the item, notnull
item
- the updated itemReturns:
the component that should represent the updated item, not
null
-
getItemKey
Gets a unique key for a given item. Items with the same keys are considered equal.
Parameters:
item
- the model itemReturns:
a unique key for the item
-
registerRenderedComponent
Appends the component to the container and registers it for future use during the lifecycle of the generator.
Parameters:
itemKey
- the key of the model itemcomponent
- the component to be attached to the container -
getRenderedComponent
-