Class ComponentUtils

java.lang.Object
com.vaadin.browserless.internal.ComponentUtils

public final class ComponentUtils extends Object
Utilities for working with Components.

For internal use only. May be renamed or removed in a future release.

  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getCaption(com.vaadin.flow.component.Component component)
    Determines the caption of given component: the first non-null caption provided by a registered ComponentSupport (for example the text of a Button), otherwise getLabel(Component).
    static String
    getLabel(com.vaadin.flow.component.Component component)
    Determines the label of given component: HasLabel.getLabel() for components that have one, otherwise the first non-null label provided by a registered ComponentSupport (for example the text in the label slot of a FormItem), otherwise the label property of the element.
    static String
    getPlaceholder(com.vaadin.flow.component.Component component)
    A component placeholder, usually shown when there's no value selected.
    static void
    simulateClosedEvent(com.vaadin.flow.component.Component component)
    Sets up an event listener for overlay components that fires a closed DOM event when the component is closed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPlaceholder

      public static String getPlaceholder(com.vaadin.flow.component.Component component)
      A component placeholder, usually shown when there's no value selected. Not all components support a placeholder; those that don't will return null.
      Parameters:
      component - the component, not null.
      Returns:
      the placeholder, or null.
    • getLabel

      public static String getLabel(com.vaadin.flow.component.Component component)
      Determines the label of given component: HasLabel.getLabel() for components that have one, otherwise the first non-null label provided by a registered ComponentSupport (for example the text in the label slot of a FormItem), otherwise the label property of the element. Returns an empty string when there is no label.

      getCaption(Component) is displayed directly on the component while label is displayed next to the component in a layout (e.g. a TextField nested in a form layout).

      Vote for issue #3241.

      Parameters:
      component - the component, not null.
      Returns:
      the label, never null.
      See Also:
    • getCaption

      public static String getCaption(com.vaadin.flow.component.Component component)
      Determines the caption of given component: the first non-null caption provided by a registered ComponentSupport (for example the text of a Button), otherwise getLabel(Component).

      Caption is generally displayed directly on the component (e.g. the Button text), while label is displayed next to the component in a layout (e.g. a TextField nested in a form layout).

      Parameters:
      component - the component, not null.
      Returns:
      the caption.
      See Also:
    • simulateClosedEvent

      public static void simulateClosedEvent(com.vaadin.flow.component.Component component)
      Sets up an event listener for overlay components that fires a closed DOM event when the component is closed. This simulates the event being fired from the browser after the closing animation has finished.
      Parameters:
      component - the component, not null.