Package com.vaadin.flow.data.renderer
Class BasicRenderer<SOURCE,TARGET>
java.lang.Object
com.vaadin.flow.data.renderer.Renderer<SOURCE>
com.vaadin.flow.data.renderer.LitRenderer<SOURCE>
com.vaadin.flow.data.renderer.ComponentRenderer<Component,SOURCE>
com.vaadin.flow.data.renderer.BasicRenderer<SOURCE,TARGET>
- Type Parameters:
SOURCE- the type of the item used inside the rendererTARGET- the type of the output object, such as Number or LocalDate
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
LocalDateRenderer,LocalDateTimeRenderer,NativeButtonRenderer,NumberRenderer,TextRenderer
Abstract renderer used as the base implementation for renderers that outputs
a simple value in the UI, such as
NumberRenderer and
LocalDateRenderer.
For components that use a client-side renderer, such as Grid or
ComboBox, the BasicRenderer works as a LitRenderer
with a preconfigured template. It also implements the
ComponentRenderer API, so components that use renderers server-side
to generate content, such as RadioButtonGroup or ListBox, can
use it as well.- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBasicRenderer(ValueProvider<SOURCE, TARGET> valueProvider) Builds a new renderer using the value provider as the source of values to be rendered. -
Method Summary
Modifier and TypeMethodDescriptioncreateComponent(SOURCE item) Creates a component for a given object model item.protected StringgetFormattedValue(TARGET object) Gets the String representation of the target object, to be used inside the template.protected StringReturns the Lit template expression used to render items.protected ValueProvider<SOURCE,TARGET> Methods inherited from class com.vaadin.flow.data.renderer.ComponentRenderer
render, updateComponentMethods inherited from class com.vaadin.flow.data.renderer.LitRenderer
getValueProviders, of, withFunction, withFunction, withProperty
-
Constructor Details
-
BasicRenderer
Builds a new renderer using the value provider as the source of values to be rendered.- Parameters:
valueProvider- the callback to provide a objects to the renderer, notnull
-
-
Method Details
-
getTemplateExpression
Description copied from class:LitRendererReturns the Lit template expression used to render items.- Overrides:
getTemplateExpressionin classComponentRenderer<Component,SOURCE> - Returns:
- the template expression
-
getValueProvider
-
createComponent
Description copied from class:ComponentRendererCreates a component for a given object model item. Subclasses can override this method to provide specific behavior.- Overrides:
createComponentin classComponentRenderer<Component,SOURCE> - Parameters:
item- the model item, possiblynull- Returns:
- a component instance representing the provided item
-
getFormattedValue
Gets the String representation of the target object, to be used inside the template.By default it uses
String.valueOf(Object)of the object.- Parameters:
object- the target object- Returns:
- the string representation of the object
-