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
A
DataGenerator that
manages the creation and passivation of components generated by
ComponentRenderers. 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 ComponentcreateComponent(T item) Creates a new component based on the provided item.voidgenerateData(T item, tools.jackson.databind.node.ObjectNode jsonObject) Adds custom data for the given item to its serializedObjectNoderepresentation.ComponentRenderer<? extends Component, T> protected ElementGets the element where the generated components will be attached to.protected StringgetItemKey(T item) Gets a unique key for a given item.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 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:DataGeneratorAdds custom data for the given item to its serializedObjectNoderepresentation. 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: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
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
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
Description copied from class:AbstractComponentDataGeneratorGets the element where the generated components will be attached to.- Specified by:
getContainerin classAbstractComponentDataGenerator<T>- Returns:
- the container
-
setContainer
-
getComponentRenderer
-
getNodeIdPropertyName
-
setNodeIdPropertyName
-