Class ValueLabel<T>

Type Parameters:
T - the value type.
All Implemented Interfaces:
IsEditor<LeafValueEditor<T>>, HasAttachHandlers, HasHandlers, HasDirectionEstimator, EventListener, TakesValue<T>, HasAutoHorizontalAlignment, HasHorizontalAlignment, HasVisibility, HasWordWrap, IsWidget
Direct Known Subclasses:
DateLabel, NumberLabel

public class ValueLabel<T> extends LabelBase<T> implements TakesValue<T>, IsEditor<LeafValueEditor<T>>
A label displaying its value through a renderer.
  • Constructor Details

    • ValueLabel

      public ValueLabel()
    • ValueLabel

      @UiConstructor public ValueLabel(Renderer<? super T> renderer)
      Creates an empty value label.
      Parameters:
      renderer -
    • ValueLabel

      protected ValueLabel(Element element, Renderer<? super T> renderer)
      This constructor may be used by subclasses to explicitly use an existing element. This element must be either a <span> or a <div> element.
      Parameters:
      element - the element to be used
  • Method Details

    • wrap

      public static <T> ValueLabel<T> wrap(Element element, Renderer<? super T> renderer)
      Creates a ValueLabel widget that wraps an existing <span> element.

      The ValueLabel's value will be null, whether the element being wrapped has content or not. Use wrap(Element, Renderer, Parser) to parse the initial element's content to initialize the ValueLabel's value.

      This element must already be attached to the document. If the element is removed from the document, you must call Widget.removeFromParent().

      Parameters:
      element - the element to be wrapped
      renderer - the renderer used to render values into the element
    • wrap

      public static <T> ValueLabel<T> wrap(Element element, Renderer<? super T> renderer, Parser<? extends T> parser) throws ParseException
      Creates a ValueLabel widget that wraps an existing <span> element.

      The ValueLabel's value will be initialized with the element's content, passed through the parser.

      This element must already be attached to the document. If the element is removed from the document, you must call Widget.removeFromParent().

      Parameters:
      element - the element to be wrapped
      renderer - the renderer used to render values into the element
      parser - the parser used to initialize the ValueLabel's value from the element's content
      Throws:
      ParseException
    • asEditor

      public LeafValueEditor<T> asEditor()
      Description copied from interface: IsEditor
      Returns the Editor encapsulated by the view object.
      Specified by:
      asEditor in interface IsEditor<T>
      Returns:
      an Editor of type E
    • getValue

      public T getValue()
      Description copied from interface: TakesValue
      Returns the current value.
      Specified by:
      getValue in interface TakesValue<T>
      Returns:
      the value as an object of type V
      See Also:
    • setValue

      public void setValue(T value)
      Description copied from interface: TakesValue
      Sets the value.
      Specified by:
      setValue in interface TakesValue<T>
      Parameters:
      value - a value object of type V
      See Also: