Class MenuRegistry
For internal use only. May be renamed or removed in a future release.
- Since:
- 24.5
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidFor internal use only.static voidcollectAndAddServerMenuItems(RouteConfiguration routeConfiguration, List<BeforeEnterListener> accessControls, Map<String, AvailableViewInfo> menuRoutes) Collect all active and accessible server menu items.static voidcollectAndAddServerMenuItems(RouteConfiguration routeConfiguration, Map<String, AvailableViewInfo> menuRoutes) Collect all active and accessible server menu items.static Map<String, AvailableViewInfo> collectClientMenuItems(boolean filterClientViews, AbstractConfiguration configuration) Collect all available client routes.static Map<String, AvailableViewInfo> collectClientMenuItems(boolean filterClientViews, AbstractConfiguration configuration, VaadinRequest vaadinRequest) Collect all available client routes.static Map<String, AvailableViewInfo> Collect views with menu annotation for automatic menu population.static List<AvailableViewInfo> Collect ordered list of views with menu annotation for automatic menu population.static List<AvailableViewInfo> collectMenuItemsList(Locale locale) Collect ordered list of views with menu annotation for automatic menu population.static ClassLoaderGet the current thread ContextClassLoader.static Map<String, AvailableViewInfo> getClientRoutes(boolean excludeLayouts) Get available client routes, optionally excluding any layout targets.getClientRoutes(boolean filterClientViews, AbstractConfiguration configuration) Get registered client routes.static Map<String, AvailableViewInfo> getMenuItems(boolean filterClientViews) Collect views with menu annotation for automatic menu population.static StringGet page title for route or simple name if no PageTitle is set.static StringgetTitle(Class<? extends Component> target, RouteParameters parameters) Get page title for route or simple name if no PageTitle is set.static URLgetViewsJsonAsResource(AbstractConfiguration configuration) Load views json as a resource.static booleanhasClientRoute(String route) See if there is a client route available for given route path.static booleanhasClientRoute(String route, boolean excludeLayouts) See if there is a client route available for given route path, optionally excluding layouts (routes with children) from the check.static booleanhasHillaMainLayout(AbstractConfiguration configuration) Determines whether the application contains a Hilla automatic main layout.
-
Field Details
-
FILE_ROUTES_JSON_NAME
- See Also:
-
FILE_ROUTES_JSON_PROD_PATH
- See Also:
-
-
Constructor Details
-
MenuRegistry
public MenuRegistry()
-
-
Method Details
-
collectMenuItems
Collect views with menu annotation for automatic menu population. All client views are collected and any accessible server views.- Returns:
- routes with view information
-
collectMenuItemsList
Collect ordered list of views with menu annotation for automatic menu population. All client views are collected and any accessible server views.- Returns:
- ordered routes with view information
-
collectMenuItemsList
Collect ordered list of views with menu annotation for automatic 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 routes with view information
-
getMenuItems
Collect views with menu annotation for automatic menu population. All client views are collected and any accessible server views.- Parameters:
filterClientViews-trueto filter routes by authentication status- Returns:
- routes with view information
-
collectAndAddServerMenuItems
public static void collectAndAddServerMenuItems(RouteConfiguration routeConfiguration, Map<String, AvailableViewInfo> menuRoutes) Collect all active and accessible server menu items.- Parameters:
routeConfiguration- routeConfiguration to usemenuRoutes- map to add route data into
-
collectAndAddServerMenuItems
public static void collectAndAddServerMenuItems(RouteConfiguration routeConfiguration, List<BeforeEnterListener> accessControls, Map<String, AvailableViewInfo> menuRoutes) Collect all active and accessible server menu items.- Parameters:
routeConfiguration- routeConfiguration to useaccessControls- extra access controls if neededmenuRoutes- map to add route data into
-
getTitle
Get page title for route or simple name if no PageTitle is set.Resolves a
DynamicPageTitlegenerator with empty route parameters when one is configured. UsegetTitle(Class, RouteParameters)to pass the actual route parameters to the generator.- Parameters:
target- route class to get title for- Returns:
- title to use for route
-
getTitle
Get page title for route or simple name if no PageTitle is set.When the route declares a
DynamicPageTitle, its generator is resolved with the given route parameters without instantiating the route class. This allows resolving titles for routes that are not currently shown, such as the entries of a breadcrumb trail.- Parameters:
target- route class to get title forparameters- the route parameters handed to aPageTitleGenerator, notnull- Returns:
- title to use for route
- Since:
- 25.2
-
collectClientMenuItems
public static Map<String,AvailableViewInfo> collectClientMenuItems(boolean filterClientViews, AbstractConfiguration configuration) Collect all available client routes.- Parameters:
filterClientViews-trueto filter routes by authentication statusconfiguration- application configuration- Returns:
- map of registered routes
-
getClientRoutes
public static List<String> getClientRoutes(boolean filterClientViews, AbstractConfiguration configuration) Get registered client routes. Possible to have all routes or only accessible routes.- Parameters:
filterClientViews-trueto filter routes by authentication statusconfiguration- application configuration- Returns:
- list of available client routes
-
collectClientMenuItems
public static Map<String,AvailableViewInfo> collectClientMenuItems(boolean filterClientViews, AbstractConfiguration configuration, VaadinRequest vaadinRequest) Collect all available client routes.- Parameters:
filterClientViews-trueto filter routes by authentication statusconfiguration- application configurationvaadinRequest- current request- Returns:
- map of registered routes
-
hasHillaMainLayout
Determines whether the application contains a Hilla automatic main layout.This method detects only a top-level main layout, when the following conditions are met:
- only one single root element is present in
file-routes.json - this element has no or blank
routeparameter - this element has non-null children array, which may or may not be empty
This method doesn't check nor does it detect the nested layouts, i.e. that are not root entries.
- Parameters:
configuration- theAbstractConfigurationcontaining the application configuration- Returns:
trueif a Hilla automatic main layout is present in the configuration,falseotherwise
- only one single root element is present in
-
getViewsJsonAsResource
Load views json as a resource.- Parameters:
configuration- current application configuration- Returns:
- URL to json resource
-
getClassLoader
Get the current thread ContextClassLoader.Note! public for testing.
- Returns:
- ClassLoader
-
hasClientRoute
See if there is a client route available for given route path.- Parameters:
route- route path to check- Returns:
- true if a client route is found.
-
clearFileRoutesCache
public static void clearFileRoutesCache()For internal use only.Clears file routes cache when running in production. Only used in tests and should not be needed in projects.
-
hasClientRoute
See if there is a client route available for given route path, optionally excluding layouts (routes with children) from the check.- Parameters:
route- route path to checkexcludeLayouts- true to exclude layouts from the check, false to include them- Returns:
- true if a client route is found.
-
getClientRoutes
Get available client routes, optionally excluding any layout targets.- Parameters:
excludeLayouts- true to exclude layouts from the check, false to include them- Returns:
- Map of client routes available
-