com.vaadin.flow.server.

Interface RouteRegistry

    • Method Detail

      • setRoute

        void setRoute(String path,
                      Class<? extends Component> navigationTarget,
                      List<Class<? extends RouterLayout>> parentChain)

        Register a navigation target with specified path and given parent layout chain. Any ParentLayout, Route or RouteAlias will be ignored in route handling.

        Parameters:

        path - path to register navigation target to

        navigationTarget - navigation target to register into session scope

        parentChain - chain of parent layouts that should be used with this target

        Throws:

        InvalidRouteConfigurationException - thrown if exact route already defined in this scope

      • removeRoute

        void removeRoute(Class<? extends Component> navigationTarget)

        Remove the given navigation target route registration. Path where the navigation target was may still be usable, e.g. we remove target with url param and there is left a non param target, but will not return the removed target.

        Note! this will remove target route and if possible any RouteAlias route that can be found for the class.

        Parameters:

        navigationTarget - navigation target class to remove

      • removeRoute

        void removeRoute(String path)

        Remove all registrations for given path. This means that any navigation target registered on the given path will be removed. But if a removed navigationTarget for the path exists it is then stored with a new main path so it can still get a resolved url.

        E.g. path "home" contains HomeView and DetailsView[String path param] both will be removed.

        Note! The restored path will be the first found match for all paths that are registered.

        Parameters:

        path - path for which to remove all navigation targets

      • removeRoute

        void removeRoute(String path,
                         Class<? extends Component> navigationTarget)

        Remove only the specified navigationTarget from the path and not the whole path if other targets exist for path. If no other targets exist whole route will be cleared.

        This will leave any other targets for path e.g. removing the wildcard path will still leave the optional target.

        Note! If another path exists for the removed navigation target it will get a new main path so it can still get a resolved url. The restored path will be the first found match for all paths that are registered.

        Parameters:

        path - path to remove from registry

        navigationTarget - path navigation target to remove

      • getRegisteredRoutes

        List<RouteData> getRegisteredRoutes()

        Get the RouteData for all registered navigation targets.

        Returns:

        list of routes available for this registry

      • getNavigationTarget

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

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

        Note! If a path has been specifically removed from a registry it will not be served from possible higher lever registries either.

        Parameters:

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

        Returns:

        optional of the navigation target corresponding to the given path

      • getNavigationTarget

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

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

        Note! If a path has been specifically removed from a registry it will not be served from possible higher lever registries either.

        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

      • getTargetUrl

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

        Get the url string for given navigation target.

        Will return Optional.empty is navigation target was not found.

        Parameters:

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

        Returns:

        optional navigation target url string

      • getRouteLayouts

        List<Class<? extends RouterLayout>> getRouteLayouts(String path,
                                                            Class<? extends Component> navigationTarget)

        Get the layout chain for given navigation target on the targeted path.

        This chain may be pre-defined or generated from annotation data.

        Parameters:

        path - path to use for resolving chain

        navigationTarget - navigation target to get layout chain for

        Returns:

        layout chain of target

      • update

        void update(Command command)

        Block updates to the registry configuration from other threads until update command has completed. This makes the command changes atomic for the registry as no one else can change the registry state during the command.

        Any other thread trying to configure current registry will be blocked until the update has released all the locks.

        Parameters:

        command - command to execute for the update

      • addRoutesChangeListener

        Registration addRoutesChangeListener(RoutesChangedListener listener)

        Adds the given route change listener to the registry.

        Parameters:

        listener - listener to be informed on route changes

        Returns:

        registration to remove the listener

      • clean

        void clean()

        Clear all registered routes from the registry.