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>
ADataGeneratorthat manages the creation and passivation of components generated byComponentRenderers. It also manages the generation of thenodeIdproperty needed by theflow-component-rendererwebcomponent.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 ComponentcreateComponent(T item)Creates a new component based on the provided item.voidgenerateData(T item, elemental.json.JsonObject jsonObject)Adds custom data for the given item to its serializedJsonObjectrepresentation.ComponentRenderer<? extends Component,T>getComponentRenderer()protected ElementgetContainer()Gets the element where the generated components will be attached to.protected StringgetItemKey(T item)Gets a unique key for a given item.StringgetNodeIdPropertyName()voidsetContainer(Element container)voidsetNodeIdPropertyName(String nodeIdPropertyName)protected ComponentupdateComponent(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:DataGeneratorAdds custom data for the given item to its serializedJsonObjectrepresentation. 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:AbstractComponentDataGeneratorCreates a new component based on the provided item.- Specified by:
createComponentin classAbstractComponentDataGenerator<T>- Parameters:
item- the data item, possiblynull- Returns:
- a
Componentwhich represents the provided item
-
updateComponent
protected Component updateComponent(Component currentComponent, T item)
Description copied from class:AbstractComponentDataGeneratorUpdates an existing component after the item has been updated. By default, it creates a new component instance viaAbstractComponentDataGenerator.createComponent(Object).- Overrides:
updateComponentin classAbstractComponentDataGenerator<T>- Parameters:
currentComponent- the current component used to represent the item, notnullitem- the updated item- Returns:
- the component that should represent the updated item, not
null
-
getItemKey
protected String getItemKey(T item)
Description copied from class:AbstractComponentDataGeneratorGets a unique key for a given item. Items with the same keys are considered equal.- Specified by:
getItemKeyin classAbstractComponentDataGenerator<T>- Parameters:
item- the model item- Returns:
- a unique key for the item
-
getContainer
protected Element getContainer()
Description copied from class:AbstractComponentDataGeneratorGets the element where the generated components will be attached to.- Specified by:
getContainerin 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)
-
-