Class MenuConfiguration

java.lang.Object
com.vaadin.flow.server.menu.MenuConfiguration

public final class MenuConfiguration extends Object
Menu configuration helper class to retrieve available menu entries for application main menu.
Since:
24.5
  • Constructor Details

    • MenuConfiguration

      public MenuConfiguration()
  • Method Details

    • getMenuEntries

      public static List<MenuEntry> getMenuEntries()
      Collect ordered list of menu entries for menu population. All client views are collected and any accessible server views.
      Returns:
      ordered list of MenuEntry instances
    • getMenuEntries

      public static List<MenuEntry> getMenuEntries(Locale locale)
      Collect ordered list of menu entries for menu population. All client views are collected and any accessible server views.
      Parameters:
      locale - locale to use for ordering. null for default locale.
      Returns:
      ordered list of MenuEntry instances
    • getPageHeader

      public static Optional<String> getPageHeader(Component content)
      Retrieves the page header of the currently shown view. Can be used in Flow main layouts to render a page header.

      Attempts to retrieve header from the following sources:

      For server-side routes it falls back to route's Java class name, if a non-null content is given. For client-side views it falls back to the React element's function name, if a page header couldn't be retrieved from the ViewConfig.

      Use getPageHeader() method, if a content object is not available.

      Parameters:
      content - as a Component class that represents a content in layout, can be null, if unavailable.
      Returns:
      optional page header for layout
    • getPageHeader

      public static Optional<String> getPageHeader()
      Retrieves the page header of the currently shown view. Can be used in Flow main layouts to render a page header.

      Attempts to retrieve header from the following sources:

      For server-side routes it falls back to route's Java class name. For client-side views it falls back to the React element's function name, if a page header couldn't be retrieved from the ViewConfig.

      Note that the possible sources of page header are limited to only available views in automatic menu configuration. If a route has a mandatory route parameters or has a route template, then it won't be used as a possible header source, even if it's shown.

      Use getPageHeader(Component) if content object is available, e.g. in RouterLayout based layouts.

      Returns:
      optional page header for layout