Class BasicRenderer<SOURCE,TARGET>

Type Parameters:
SOURCE - the type of the item used inside the renderer
TARGET - the type of the output object, such as Number or LocalDate
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LocalDateRenderer, LocalDateTimeRenderer, NativeButtonRenderer, NumberRenderer

public abstract class BasicRenderer<SOURCE,TARGET> extends ComponentRenderer<Component,SOURCE>
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 Details

    • BasicRenderer

      protected BasicRenderer(ValueProvider<SOURCE,TARGET> valueProvider)
      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, not null
  • Method Details

    • getTemplateExpression

      protected String getTemplateExpression()
      Description copied from class: LitRenderer
      Returns the Lit template expression used to render items.
      Overrides:
      getTemplateExpression in class ComponentRenderer<Component,SOURCE>
      Returns:
      the template expression
    • getValueProvider

      protected ValueProvider<SOURCE,TARGET> getValueProvider()
    • createComponent

      public Component createComponent(SOURCE item)
      Description copied from class: ComponentRenderer
      Creates a component for a given object model item. Subclasses can override this method to provide specific behavior.
      Overrides:
      createComponent in class ComponentRenderer<Component,SOURCE>
      Parameters:
      item - the model item, possibly null
      Returns:
      a component instance representing the provided item
    • getFormattedValue

      protected String getFormattedValue(TARGET object)
      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