Menu Configuration
To generate a custom menu, the MenuConfiguration may be used for collecting defined server and client routes. Client routes are taken from the FileSystem routes definition. Server routes come from routes annotated with @Menu.
The collected menu items are filtered by access control from the UI (i.e., NavigationAccessControl and ViewAccessChecker). If the application has login and route defined Roles, the returned list is filtered on only available routes.
Creating Routes Menu
For a Flow application, any route annotated with @Menu is eligible for collection.
To get the available menu routes, call the static method MenuConfiguration.getMenuEntries(). This returns a List<MenuEntry>, first sorted in order found, then by path alphabetically and locale. It makes creating a simple menu by using Anchor, which can look like this:
Source code
Java
List<MenuEntry> menuEntries = MenuConfiguration.getMenuEntries();
menuEntries.forEach(entry -> layout.add(new Anchor(entry.path(), entry.title())));Data Returned for Menu Entries
The MenuEntry for a route contains information on the route. Using this data, it’s possible to populate a menu, automatically.
The data contained is as follows:
path-
Route path that should be used for navigation.
title-
Title set in the
@Menuannotation or the@PageTitle, if defined — otherwise, the class simple name. For the client, title is populated from the FS router data. order-
Order number for the menu entry, if defined.
icon-
Icon to use in the menu. This value can be entered inside a
<vaadin-icon>element’siconattribute. It accepts icon group and a name likevaadin:file. Or the value can be given in<vaadin-icon>element’ssrcattribute, which takes the path to the icon (e.g.,line-awesome/svg/lock-open-solid.svg). menuClass-
Source class of the
@Menuannotation. Always null for client routes.
647922A8-D542-4FA7-AAF6-44D40FC6A33B