Class Navigator.UriFragmentManager

  • All Implemented Interfaces:
    NavigationStateManager, java.io.Serializable
    Enclosing class:
    Navigator

    public static class Navigator.UriFragmentManager
    extends java.lang.Object
    implements NavigationStateManager
    A NavigationStateManager using hashbang fragments in the Page location URI to track views and enable listening to view changes.

    A hashbang URI is one where the optional fragment or "hash" part - the part following a # sign - is used to encode navigation state in a web application. The advantage of this is that the fragment can be dynamically manipulated by javascript without causing page reloads.

    This class is mostly for internal use by Navigator, and is only public and static to enable testing.

    Note: Since 8.2 you can use Navigator.PushStateManager, which is based on HTML5 History API. To use it, add PushStateNavigation annotation to the UI.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      UriFragmentManager​(Page page)
      Creates a new URIFragmentManager and attach it to listen to URI fragment changes of a Page.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String getFragment()
      Returns the current URI fragment tracked by this UriFragentManager.
      java.lang.String getState()
      Returns the current navigation state including view name and any optional parameters.
      protected void setFragment​(java.lang.String fragment)
      Sets the URI fragment to the given string.
      void setNavigator​(Navigator navigator)
      Sets the Navigator used with this state manager.
      void setState​(java.lang.String state)
      Sets the current navigation state in the location URI or similar location, including view name and any optional parameters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UriFragmentManager

        public UriFragmentManager​(Page page)
        Creates a new URIFragmentManager and attach it to listen to URI fragment changes of a Page.
        Parameters:
        page - page whose URI fragment to get and modify
    • Method Detail

      • setNavigator

        public void setNavigator​(Navigator navigator)
        Description copied from interface: NavigationStateManager
        Sets the Navigator used with this state manager. The state manager should notify the provided navigator of user-triggered navigation state changes by invoking navigator.navigateTo(getState()). navigator parameter value could be null if previously set navigator is destroyed.

        This method should only be called by a Navigator.

        Specified by:
        setNavigator in interface NavigationStateManager
      • getState

        public java.lang.String getState()
        Description copied from interface: NavigationStateManager
        Returns the current navigation state including view name and any optional parameters.
        Specified by:
        getState in interface NavigationStateManager
        Returns:
        current view and parameter string, not null
      • setState

        public void setState​(java.lang.String state)
        Description copied from interface: NavigationStateManager
        Sets the current navigation state in the location URI or similar location, including view name and any optional parameters.

        This method should be only called by a Navigator.

        Specified by:
        setState in interface NavigationStateManager
        Parameters:
        state - new view and parameter string, not null
      • getFragment

        protected java.lang.String getFragment()
        Returns the current URI fragment tracked by this UriFragentManager.
        Returns:
        The URI fragment.
      • setFragment

        protected void setFragment​(java.lang.String fragment)
        Sets the URI fragment to the given string.
        Parameters:
        fragment - The new URI fragment.