COMPONENT
- the type of the output componentSOURCE
- the type of the input model objectpublic class ComponentRenderer<COMPONENT extends Component,SOURCE> extends Renderer<SOURCE>
Component
s.
Components that support renderers should use the appropriate method from this
class to provide component rendering: Renderer.render(Element, DataKeyMapper)
for components that uses <template>
, and
createComponent(Object)
for components that use light-dom.
Modifier | Constructor and Description |
---|---|
protected |
ComponentRenderer()
Default constructor, that can be used by subclasses which supports
different ways of creating components, other than those defined in the
other constructors.
|
|
ComponentRenderer(SerializableFunction<SOURCE,COMPONENT> componentFunction)
Creates a new ComponentRenderer that uses the componentFunction to
generate new
Component instances. |
|
ComponentRenderer(SerializableFunction<SOURCE,COMPONENT> componentFunction,
SerializableBiFunction<Component,SOURCE,Component> componentUpdateFunction)
|
|
ComponentRenderer(SerializableSupplier<COMPONENT> componentSupplier)
Creates a new ComponentRenderer that uses the componentSupplier to
generate new
Component instances. |
|
ComponentRenderer(SerializableSupplier<COMPONENT> componentSupplier,
SerializableBiConsumer<COMPONENT,SOURCE> itemConsumer)
Creates a new ComponentRenderer that uses the componentSupplier to
generate new
Component instances, and the itemConsumer to set the
related items. |
Modifier and Type | Method and Description |
---|---|
COMPONENT |
createComponent(SOURCE item)
Creates a component for a given object model item.
|
Rendering<SOURCE> |
render(Element container,
DataKeyMapper<SOURCE> keyMapper,
Element contentTemplate)
Handles the rendering of the model objects by using the given
<template> element in the given container. |
void |
setComponentRendererTag(String componentRendererTag)
Sets the tag of the webcomponent used at the client-side to manage
component rendering inside
<template> . |
Component |
updateComponent(Component currentComponent,
SOURCE item)
Called when the item is updated.
|
getEventHandlers, getValueProviders, render, setEventHandler, setProperty
public ComponentRenderer(SerializableSupplier<COMPONENT> componentSupplier, SerializableBiConsumer<COMPONENT,SOURCE> itemConsumer)
Component
instances, and the itemConsumer to set the
related items.
Some components may support several rendered components at once, so different component instances should be created for each different item for those components.
componentSupplier
- a supplier that can generate new component instancesitemConsumer
- a setter for the corresponding item for the rendered componentpublic ComponentRenderer(SerializableSupplier<COMPONENT> componentSupplier)
Component
instances.
This constructor is a convenient way of providing components to a template when the actual model item doesn't matter for the component instance.
Some components may support several rendered components at once, so different component instances should be created for each different item for those components.
componentSupplier
- a supplier that can generate new component instancespublic ComponentRenderer(SerializableFunction<SOURCE,COMPONENT> componentFunction)
Component
instances. The function takes a model item
and outputs a component instance.
Some components may support several rendered components at once, so different component instances should be created for each different item for those components.
componentFunction
- a function that can generate new component instancesComponentRenderer(SerializableFunction, SerializableBiFunction)
public ComponentRenderer(SerializableFunction<SOURCE,COMPONENT> componentFunction, SerializableBiFunction<Component,SOURCE,Component> componentUpdateFunction)
Component
instances, and a componentUpdateFunction
to update existing Component
instances.
The componentUpdateFunction can return a different component than the one previously created. In those cases, the new instance is used, and the old is discarded.
Some components may support several rendered components at once, so different component instances should be created for each different item for those components.
componentFunction
- a function that can generate new component instancescomponentUpdateFunction
- a function that can update the existing component instance for
the item, or generate a new component based on the item
update. When the function is null
, the
componentFunction is always used insteadprotected ComponentRenderer()
public Rendering<SOURCE> render(Element container, DataKeyMapper<SOURCE> keyMapper, Element contentTemplate)
Renderer
<template>
element in the given container.
Subclasses of Renderer usually override this method to provide additional features.
render
in class Renderer<SOURCE>
container
- the element in which the template will be attached to, not
null
keyMapper
- mapper used internally to fetch items by key and to provide
keys for given items. It is required when either event
handlers or DataGenerator
are supportedcontentTemplate
- the <template>
element to be used for rendering in the
container, not null
public void setComponentRendererTag(String componentRendererTag)
<template>
. By default it uses
<flow-component-renderer>
.componentRendererTag
- the tag of the client-side webcomponent for component
rendering, not null
public COMPONENT createComponent(SOURCE item)
item
- the model item, possibly null
public Component updateComponent(Component currentComponent, SOURCE item)
Component
is
created (via createComponent(Object)
) when the item is updated,
but setting a update function via the
ComponentRenderer(SerializableFunction, SerializableBiFunction)
can change the behavior.currentComponent
- the current component used to render the item, not
null
item
- the updated itemnull
.Copyright © 2025. All rights reserved.