SOURCE
- the type of the input object used inside the templatepublic class Renderer<SOURCE> extends Object implements Serializable
ValueProvider
,
ComponentRenderer
,
LitRenderer
,
https://www.polymer-project.org/2.0/docs/devguide/templates,
Serialized FormModifier | Constructor and Description |
---|---|
protected |
Renderer()
Default constructor.
|
protected |
Renderer(String template)
Deprecated.
since Vaadin 22
|
Modifier and Type | Method and Description |
---|---|
Map<String,SerializableConsumer<SOURCE>> |
getEventHandlers()
Deprecated.
since Vaadin 22
|
Map<String,ValueProvider<SOURCE,?>> |
getValueProviders()
Gets the property mapped to
ValueProvider s in this renderer. |
Rendering<SOURCE> |
render(Element container,
DataKeyMapper<SOURCE> keyMapper)
Handles the rendering of the model objects by creating a new
<template> element in the given container. |
Rendering<SOURCE> |
render(Element container,
DataKeyMapper<SOURCE> keyMapper,
Element contentTemplate)
Deprecated.
since Vaadin 22
|
protected void |
setEventHandler(String handlerName,
SerializableConsumer<SOURCE> handler)
Deprecated.
since Vaadin 22
|
protected void |
setProperty(String property,
ValueProvider<SOURCE,?> provider)
Deprecated.
since Vaadin 22
|
protected Renderer()
@Deprecated protected Renderer(String template)
template
- the template used by the renderer@Deprecated protected void setProperty(String property, ValueProvider<SOURCE,?> provider)
[[item.property]]
syntax.
Examples:
// Regular property
TemplateRenderer.<Person> of("<div>Name: [[item.name]]</div>")
.withProperty("name", Person::getName);
// Property that uses a bean. Note that in this case the entire "Address" object will be sent to the template.
// Note that even properties of the bean which are not used in the template are sent to the client, so use
// this feature with caution.
TemplateRenderer.<Person> of("<span>Street: [[item.address.street]]</span>")
.withProperty("address", Person::getAddress);
// In this case only the street field inside the Address object is sent
TemplateRenderer.<Person> of("<span>Street: [[item.street]]</span>")
.withProperty("street", person -> person.getAddress().getStreet());
Any types supported by the JsonSerializer
are valid types for the
Renderer.property
- the name of the property used inside the template, not
null
provider
- a ValueProvider
that provides the actual value for the
property, not null
@Deprecated protected void setEventHandler(String handlerName, SerializableConsumer<SOURCE> handler)
on-event
syntax.
Examples:
// Standard event
TemplateRenderer.of("<button on-click='handleClick'>Click me</button>")
.withEventHandler("handleClick", object -> doSomething());
// You can handle custom events from webcomponents as well, using the same syntax
TemplateRenderer.of("<my-webcomponent on-customevent=
'onCustomEvent'></my-webcomponent>")
.withEventHandler("onCustomEvent", object -> doSomething());
The name of the function used on the on-event
attribute should be
the name used at the handlerName parameter. This name must be a valid
Javascript function name.handlerName
- the name of the handler used inside the
on-event="handlerName"
, not null
handler
- the handler executed when the event is triggered, not
null
public Rendering<SOURCE> render(Element container, DataKeyMapper<SOURCE> keyMapper)
<template>
element in the given container.container
- the element in which the template will be attached tokeyMapper
- 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 supported@Deprecated public Rendering<SOURCE> render(Element container, DataKeyMapper<SOURCE> keyMapper, Element contentTemplate)
<template>
element in the given container.
Subclasses of Renderer usually override this method to provide additional features.
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 Map<String,ValueProvider<SOURCE,?>> getValueProviders()
ValueProvider
s in this renderer. The
returned map is immutable.null
@Deprecated public Map<String,SerializableConsumer<SOURCE>> getEventHandlers()
null
setEventHandler(String, SerializableConsumer)
Copyright © 2022. All rights reserved.