Class RouterLinkHandler


  • public class RouterLinkHandler
    extends Object
    Handler for click events originating from application navigation link elements marked with "router-link".

    Events are sent to server for handling.

    Since:
    1.0
    Author:
    Vaadin Ltd
    • Method Detail

      • bind

        public static void bind​(Registry registry,
                                elemental.dom.Element element)
        Adds a click event listener for the given element for intercepting application navigation related click events and sending them to server.
        Parameters:
        registry - the registry
        element - the element to listen to click events in
      • isInsidePageNavigation

        public static boolean isInsidePageNavigation​(String path,
                                                     boolean hasFragment)
        Checks whether the given path is for navigating inside the same page as the current one.

        If the paths are different, it is always outside the current page navigation. If they are the same, then it depends on whether the new href has any hash #.

        Parameters:
        path - the path to check against
        hasFragment - the true if the navigated url contains a fragment,false if not
        Returns:
        true if the given location is for navigating inside the current page, false if not
      • sendServerNavigationEvent

        public static void sendServerNavigationEvent​(Registry registry,
                                                     String location,
                                                     Object stateObject,
                                                     boolean routerLinkEvent)
        Notifies the server about navigation to the given location.

        Ensures that navigation works even if the session has expired.

        Parameters:
        registry - the registry
        location - the location to navigate to, relative to the base URI
        stateObject - the state object or null if none applicable
        routerLinkEvent - true if this event was triggered by interaction with a router link; false if triggered by history navigation