com.vaadin.flow.data.renderer.
Class ComponentDataGenerator<T>
Type Parameters:
T
- the date type
All Implemented Interfaces:
A DataGenerator
that
manages the creation and passivation of components generated by
ComponentRenderer
s. It also manages the generation of the
nodeId
property which is needed to get the element reference on the
client side.
This class is used internally by listing components that support ComponentRenderers.
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionComponentDataGenerator
(ComponentRenderer<? extends Component, T> componentRenderer, ValueProvider<T, String> keyMapper) Creates a new generator.
-
Method Summary
Modifier and TypeMethodDescriptionprotected Component
createComponent
(T item) Creates a new component based on the provided item.
void
generateData
(T item, elemental.json.JsonObject jsonObject) Adds custom data for the given item to its serialized
JsonObject
representation.ComponentRenderer<? extends Component,
T> protected Element
Gets the element where the generated components will be attached to.
protected String
getItemKey
(T item) Gets a unique key for a given item.
void
setContainer
(Element container) void
setNodeIdPropertyName
(String nodeIdPropertyName) protected Component
updateComponent
(Component currentComponent, T item) Updates an existing component after the item has been updated.
Methods inherited from class com.vaadin.flow.data.provider.AbstractComponentDataGenerator
destroyAllData, destroyData, getRenderedComponent, refreshData, registerRenderedComponent
-
Constructor Details
-
ComponentDataGenerator
public ComponentDataGenerator(ComponentRenderer<? extends Component, T> componentRenderer, ValueProvider<T, String> keyMapper) Creates a new generator.
Parameters:
componentRenderer
- the renderer used to produce components based on data itemskeyMapper
- the DataKeyMapper used to fetch keys for items
-
-
Method Details
-
generateData
Description copied from interface:
DataGenerator
Adds custom data for the given item to its serialized
JsonObject
representation. This JSON object will be sent to client-side DataProvider.Parameters:
item
- the data item being serializedjsonObject
- the JSON object being sent to the client -
createComponent
Description copied from class:
AbstractComponentDataGenerator
Creates a new component based on the provided item.
Specified by:
createComponent
in classAbstractComponentDataGenerator<T>
Parameters:
item
- the data item, possiblynull
Returns:
a
Component
which represents the provided item -
updateComponent
Description copied from class:
AbstractComponentDataGenerator
Updates an existing component after the item has been updated. By default, it creates a new component instance via
AbstractComponentDataGenerator.createComponent(Object)
.Overrides:
updateComponent
in classAbstractComponentDataGenerator<T>
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
Description copied from class:
AbstractComponentDataGenerator
Gets a unique key for a given item. Items with the same keys are considered equal.
Specified by:
getItemKey
in classAbstractComponentDataGenerator<T>
Parameters:
item
- the model itemReturns:
a unique key for the item
-
getContainer
Description copied from class:
AbstractComponentDataGenerator
Gets the element where the generated components will be attached to.
Specified by:
getContainer
in classAbstractComponentDataGenerator<T>
Returns:
the container
-
setContainer
-
getComponentRenderer
-
getNodeIdPropertyName
-
setNodeIdPropertyName
-