Package com.vaadin.flow.data.renderer
Class ComponentDataGenerator<T>
- java.lang.Object
-
- com.vaadin.flow.data.provider.AbstractComponentDataGenerator<T>
-
- com.vaadin.flow.data.renderer.ComponentDataGenerator<T>
-
- Type Parameters:
T
- the date type
- All Implemented Interfaces:
DataGenerator<T>
,Serializable
public class ComponentDataGenerator<T> extends AbstractComponentDataGenerator<T>
ADataGenerator
that manages the creation and passivation of components generated byComponentRenderer
s. It also manages the generation of thenodeId
property needed by theflow-component-renderer
webcomponent.This class is used internally by listing components that support ComponentRenderers.
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ComponentDataGenerator(ComponentRenderer<? extends Component,T> componentRenderer, ValueProvider<T,String> keyMapper)
Creates a new generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 serializedJsonObject
representation.ComponentRenderer<? extends Component,T>
getComponentRenderer()
protected Element
getContainer()
Gets the element where the generated components will be attached to.protected String
getItemKey(T item)
Gets a unique key for a given item.String
getNodeIdPropertyName()
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 Detail
-
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 Detail
-
generateData
public void generateData(T item, elemental.json.JsonObject jsonObject)
Description copied from interface:DataGenerator
Adds custom data for the given item to its serializedJsonObject
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
protected Component createComponent(T item)
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
protected Component updateComponent(Component currentComponent, T item)
Description copied from class:AbstractComponentDataGenerator
Updates an existing component after the item has been updated. By default, it creates a new component instance viaAbstractComponentDataGenerator.createComponent(Object)
.- Overrides:
updateComponent
in classAbstractComponentDataGenerator<T>
- Parameters:
currentComponent
- the current component used to represent the item, notnull
item
- the updated item- Returns:
- the component that should represent the updated item, not
null
-
getItemKey
protected String getItemKey(T item)
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 item- Returns:
- a unique key for the item
-
getContainer
protected Element 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
public void setContainer(Element container)
-
getComponentRenderer
public ComponentRenderer<? extends Component,T> getComponentRenderer()
-
getNodeIdPropertyName
public String getNodeIdPropertyName()
-
setNodeIdPropertyName
public void setNodeIdPropertyName(String nodeIdPropertyName)
-
-