com.vaadin.flow.server.startup.

Class RouteRegistry

    • Constructor Detail

      • RouteRegistry

        protected RouteRegistry()

        Creates a new uninitialized route registry.

    • Method Detail

      • getInstance

        public static RouteRegistry getInstance(ServletContext servletContext)

        Gets the route registry for the given servlet context. If the servlet context has no route registry, a new instance is created and assigned to the context.

        Parameters:

        servletContext - the servlet context for which to get a route registry, not null

        Returns:

        a registry instance for the given servlet context, not null

      • setErrorNavigationTargets

        public void setErrorNavigationTargets(Set<Class<? extends Component>> errorNavigationTargets)

        Set error handler navigation targets.

        Parameters:

        errorNavigationTargets - error handler navigation targets

      • getRegisteredRoutes

        public List<RouteData> getRegisteredRoutes()

        Get the RouteData for all registered navigation targets.

        Returns:

        list of routes available for this registry

      • errorNavigationTargetsInitialized

        public boolean errorNavigationTargetsInitialized()

        Returns whether this registry has been initialized with error navigation targets.

        Returns:

        whether this registry has been initialized with error navigation targets

      • getErrorNavigationTarget

        public Optional<RouteRegistry.ErrorTargetEntry> getErrorNavigationTarget(Exception exception)

        Get a registered navigation target for given exception. First we will search for a matching cause for in the exception chain and if no match found search by extended type.

        Parameters:

        exception - exception to search error view for

        Returns:

        optional error target entry corresponding to the given exception

      • getNavigationTarget

        public Optional<Class<? extends Component>> getNavigationTarget(String pathString)

        Gets the optional navigation target class for a given Location. Returns an empty optional if no navigation target corresponds to the given Location.

        Parameters:

        pathString - the path to get the navigation target for, not null

        Returns:

        optional of the navigation target corresponding to the given location

        See Also:

        Location

      • getNavigationTarget

        public Optional<Class<? extends Component>> getNavigationTarget(String pathString,
                                                                        List<String> segments)

        Gets the optional navigation target class for a given Location matching with path segments.

        Parameters:

        pathString - path to get navigation target for, not null

        segments - segments given for path

        Returns:

        optional navigation target corresponding to the given location with given segments if any applicable targets found.

        See Also:

        Location

      • hasRouteTo

        public boolean hasRouteTo(String pathString)

        Checks if the registry contains a route to the given path.

        Parameters:

        pathString - path to get navigation target for, not null

        Returns:

        true if the registry contains a route to the given path, false otherwise.

      • getTargetUrl

        public Optional<String> getTargetUrl(Class<? extends Component> navigationTarget)

        Get the url string for given navigation target.

        Parameters:

        navigationTarget - navigation target to get registered route for, not null

        Returns:

        optional navigation target url string

      • navigationTargetsInitialized

        public boolean navigationTargetsInitialized()

        Returns whether this registry has been initialized with navigation targets.

        Returns:

        whether this registry has been initialized

      • hasNavigationTargets

        public boolean hasNavigationTargets()

        Checks whether any navigation targets have been registered.

        Returns:

        true if at least one navigation target is registered; otherwise false

      • hasRoutes

        public boolean hasRoutes()

        Check if there are any registered routes.

        Returns:

        true if we have registered routes

      • getThemeFor

        public Optional<ThemeDefinition> getThemeFor(Class<?> navigationTarget,
                                                     String path)

        Gets the ThemeDefinition associated with the given navigation target, if any. The theme is defined by using the Theme annotation on the navigation target class.

        If no Theme and NoTheme annotation are used, by default the com.vaadin.flow.theme.lumo.Lumo class is used (if present on the classpath).

        Parameters:

        navigationTarget - the navigation target class

        path - the resolved route path so we can determine what the rendered target is for

        Returns:

        the associated ThemeDefinition, or empty if none is defined and the Lumo class is not in the classpath, or if the NoTheme annotation is being used.