Package com.vaadin.flow.data.renderer
Class Renderer<SOURCE>
- java.lang.Object
-
- com.vaadin.flow.data.renderer.Renderer<SOURCE>
-
- Type Parameters:
SOURCE- the type of the input object used inside the template
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ComponentRenderer,LitRenderer,TemplateRenderer
public class Renderer<SOURCE> extends Object implements Serializable
Base class for all renderers - classes that take a given model object as input and outputs a set of elements that represents that item in the UI.- Author:
- Vaadin Ltd
- See Also:
ValueProvider,ComponentRenderer,LitRenderer, https://www.polymer-project.org/2.0/docs/devguide/templates, Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Map<String,com.vaadin.flow.function.SerializableConsumer<SOURCE>>getEventHandlers()Deprecated.since Vaadin 22Map<String,com.vaadin.flow.function.ValueProvider<SOURCE,?>>getValueProviders()Deprecated.since Vaadin 23.1Rendering<SOURCE>render(com.vaadin.flow.dom.Element container, com.vaadin.flow.data.provider.DataKeyMapper<SOURCE> keyMapper)Handles the rendering of the model objects by creating a new<template>element in the given container.Rendering<SOURCE>render(com.vaadin.flow.dom.Element container, com.vaadin.flow.data.provider.DataKeyMapper<SOURCE> keyMapper, com.vaadin.flow.dom.Element contentTemplate)Deprecated.since Vaadin 22protected voidsetEventHandler(String handlerName, com.vaadin.flow.function.SerializableConsumer<SOURCE> handler)Deprecated.since Vaadin 22protected voidsetProperty(String property, com.vaadin.flow.function.ValueProvider<SOURCE,?> provider)Deprecated.since Vaadin 22
-
-
-
Constructor Detail
-
Renderer
protected Renderer()
Default constructor.
-
Renderer
@Deprecated protected Renderer(String template)
Deprecated.since Vaadin 22Builds a renderer with the specified template.- Parameters:
template- the template used by the renderer
-
-
Method Detail
-
setProperty
@Deprecated protected void setProperty(String property, com.vaadin.flow.function.ValueProvider<SOURCE,?> provider)
Deprecated.since Vaadin 22Sets a property to be used inside the template. Each property is referenced inside the template by using the[[item.property]]syntax.Examples:
Any types supported by the// 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());JsonSerializerare valid types for the Renderer.- Parameters:
property- the name of the property used inside the template, notnullprovider- aValueProviderthat provides the actual value for the property, notnull
-
setEventHandler
@Deprecated protected void setEventHandler(String handlerName, com.vaadin.flow.function.SerializableConsumer<SOURCE> handler)
Deprecated.since Vaadin 22Sets an event handler for events from elements inside the template. Each event is referenced inside the template by using theon-eventsyntax.Examples:
The name of the function used on the// 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());on-eventattribute should be the name used at the handlerName parameter. This name must be a valid Javascript function name.- Parameters:
handlerName- the name of the handler used inside theon-event="handlerName", notnullhandler- the handler executed when the event is triggered, notnull- See Also:
- https://www.polymer-project.org/2.0/docs/devguide/events
-
render
public Rendering<SOURCE> render(com.vaadin.flow.dom.Element container, com.vaadin.flow.data.provider.DataKeyMapper<SOURCE> keyMapper)
Handles the rendering of the model objects by creating a new<template>element in the given container.- Parameters:
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 orDataGeneratorare supported- Returns:
- the context of the rendering, that can be used by the components to provide extra customization
-
render
@Deprecated public Rendering<SOURCE> render(com.vaadin.flow.dom.Element container, com.vaadin.flow.data.provider.DataKeyMapper<SOURCE> keyMapper, com.vaadin.flow.dom.Element contentTemplate)
Deprecated.since Vaadin 22Handles the rendering of the model objects by using the given<template>element in the given container.Subclasses of Renderer usually override this method to provide additional features.
- Parameters:
container- the element in which the template will be attached to, notnullkeyMapper- mapper used internally to fetch items by key and to provide keys for given items. It is required when either event handlers orDataGeneratorare supportedcontentTemplate- the<template>element to be used for rendering in the container, notnull- Returns:
- the context of the rendering, that can be used by the components to provide extra customization
-
getValueProviders
@Deprecated public Map<String,com.vaadin.flow.function.ValueProvider<SOURCE,?>> getValueProviders()
Deprecated.since Vaadin 23.1Gets the property mapped toValueProviders in this renderer. The returned map is immutable.- Returns:
- the mapped properties, never
null
-
getEventHandlers
@Deprecated public Map<String,com.vaadin.flow.function.SerializableConsumer<SOURCE>> getEventHandlers()
Deprecated.since Vaadin 22Gets the event handlers linked to this renderer. The returned map is immutable.- Returns:
- the mapped event handlers, never
null - See Also:
setEventHandler(String, SerializableConsumer)
-
-