Class TextRenderer<ITEM>

Type Parameters:
ITEM - the type of the input object that can be used by the rendered component
All Implemented Interfaces:
Serializable

public class TextRenderer<ITEM> extends BasicRenderer<ITEM,ITEM>
A renderer that renders each item as a text using provided ItemLabelGenerator.
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • TextRenderer

      public TextRenderer()
      Creates a new renderer instance using the default ItemLabelGenerator: String::valueOf.
    • TextRenderer

      public TextRenderer(ItemLabelGenerator<ITEM> itemLabelGenerator)
      Creates a new renderer instance using the provided itemLabelGenerator.
      Parameters:
      itemLabelGenerator - the item label generator
  • Method Details

    • createComponent

      public Component createComponent(ITEM 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 BasicRenderer<ITEM,ITEM>
      Parameters:
      item - the model item, possibly null
      Returns:
      a component instance representing the provided item
    • createElement

      protected Element createElement(String item)
      Creates a new Element that represent the rendered item.

      By default the text is wrapped inside a <span> element. Subclasses may override this method to return some other Element.

      Parameters:
      item - the item to render
      Returns:
      the element representing rendered item
    • getFormattedValue

      protected String getFormattedValue(ITEM item)
      Description copied from class: BasicRenderer
      Gets the String representation of the target object, to be used inside the template.

      By default it uses String.valueOf(Object) of the object.

      Overrides:
      getFormattedValue in class BasicRenderer<ITEM,ITEM>
      Parameters:
      item - the target object
      Returns:
      the string representation of the object
    • getTemplateExpression

      protected String getTemplateExpression()
      Description copied from class: LitRenderer
      Returns the Lit template expression used to render items.
      Overrides:
      getTemplateExpression in class BasicRenderer<ITEM,ITEM>
      Returns:
      the template expression