com.vaadin.flow.component.dashboard.

Class DashboardWidget

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.dashboard.DashboardWidget

All Implemented Interfaces:

AttachNotifier, DetachNotifier, HasElement, HasStyle, Serializable

@Tag("vaadin-dashboard-widget") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.6.3") @NpmPackage(value="@vaadin/dashboard",version="24.6.3") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/dashboard/src/vaadin-dashboard-widget.js") public class DashboardWidget extends Component

DashboardWidget represents a customizable widget that can be placed within a Dashboard. It supports layout options such as colspan and rowspan, and allows setting content and header content.

Author:

Vaadin Ltd

See Also:

  • Constructor Details

    • DashboardWidget

      public DashboardWidget()

      Creates an empty widget.

    • DashboardWidget

      public DashboardWidget(String title)

      Creates a widget with the specified title.

      Parameters:

      title - the title to set

    • DashboardWidget

      public DashboardWidget(Component content)

      Creates a widget with the specified content.

      Parameters:

      content - the content to set

    • DashboardWidget

      public DashboardWidget(String title, Component content)

      Creates a widget with the specified title and content.

      Parameters:

      title - the title to set

      content - the content to set

  • Method Details

    • getTitle

      public String getTitle()

      Returns the title of the widget.

      Returns:

      the widgetTitle property from the web component

    • setTitle

      public void setTitle(String title)

      Sets the title of the widget.

      Parameters:

      title - the title to set

    • getColspan

      public int getColspan()

      Returns the colspan of the widget. The default is 1.

      Returns:

      the colspan of the widget

    • setColspan

      public void setColspan(int colspan)

      Sets the colspan of the widget. Cannot be lower than 1.

      Parameters:

      colspan - the colspan to set

    • getRowspan

      public int getRowspan()

      Returns the rowspan of the widget. The default is 1.

      Returns:

      the rowspan of the widget

    • setRowspan

      public void setRowspan(int rowspan)

      Sets the rowspan of the widget. Cannot be lower than 1.

      Parameters:

      rowspan - the rowspan to set

    • getContent

      public Component getContent()

      Returns the content of the widget. Returns null if the widget has no content.

      Returns:

      the content of the widget

    • setContent

      public void setContent(Component content)

      Sets the content to the widget. Set null to remove the current content.

      Parameters:

      content - the content to set

    • getHeaderContent

      public Component getHeaderContent()

      Gets the content in the header content slot of this widget.

      Returns:

      the header content of this widget, or null if no header content has been set

    • setHeaderContent

      public void setHeaderContent(Component header)

      Sets the content in the header content slot of this widget, replacing any existing header content.

      Parameters:

      header - the content to set, can be null to remove existing header content

    • setVisible

      public void setVisible(boolean visible)

      Description copied from class: Component

      Sets the component visibility value.

      When a component is set as invisible, all the updates of the component from the server to the client are blocked until the component is set as visible again.

      Invisible components don't receive any updates from the client-side. Unlike the server-side updates, client-side updates, if any, are discarded while the component is invisible, and are not transmitted to the server when the component is made visible.

      Overrides:

      setVisible in class Component

      Parameters:

      visible - the component visibility value

      Throws:

      UnsupportedOperationException - Dashboard widget does not support setting visibility

    • isVisible

      public boolean isVisible()

      Description copied from class: Component

      Gets the component visibility value.

      Overrides:

      isVisible in class Component

      Returns:

      true if the component is visible, false otherwise

    • onAttach

      protected void onAttach(AttachEvent attachEvent)

      Description copied from class: Component

      Called when the component is attached to a UI.

      This method is invoked before the AttachEvent is fired for the component.

      Make sure to call super.onAttach when overriding this method.

      Overrides:

      onAttach in class Component

      Parameters:

      attachEvent - the attach event