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
    • getMenuEntriesTree

      public static List<MenuEntry> getMenuEntriesTree()
      Collect the menu entries as a hierarchy for menu population, nested according to the route hierarchy.

      The same views as getMenuEntries() are returned, but as a tree: server views are nested according to @RouteParent (with URL-prefix walking as fallback), and client views according to their file-system route nesting. Only root entries are returned; the descendants are reachable via MenuEntry.children().

      Returns:
      ordered list of root MenuEntry instances with nested children
    • getMenuEntriesTree

      public static List<MenuEntry> getMenuEntriesTree(Locale locale)
      Collect the menu entries as a hierarchy for menu population, nested according to the route hierarchy.
      Parameters:
      locale - locale to use for ordering. null for default locale.
      Returns:
      ordered list of root MenuEntry instances with nested children
      See Also:
    • 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