Package com.vaadin.navigator
Class Navigator.UriFragmentManager
- java.lang.Object
-
- com.vaadin.navigator.Navigator.UriFragmentManager
-
- All Implemented Interfaces:
NavigationStateManager,Page.UriFragmentChangedListener,Serializable
- Enclosing class:
- Navigator
public static class Navigator.UriFragmentManager extends Object implements NavigationStateManager, Page.UriFragmentChangedListener
ANavigationStateManagerusing 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.
- 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 aPage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetFragment()Returns the current URI fragment tracked by this UriFragentManager.StringgetState()Returns the current navigation state including view name and any optional parameters.protected voidsetFragment(String fragment)Sets the URI fragment to the given string.voidsetNavigator(Navigator navigator)Sets the Navigator used with this state manager.voidsetState(String state)Sets the current navigation state in the location URI or similar location, including view name and any optional parameters.voiduriFragmentChanged(Page.UriFragmentChangedEvent event)Event handler method invoked when the URI fragment of the page changes.
-
-
-
Method Detail
-
setNavigator
public void setNavigator(Navigator navigator)
Description copied from interface:NavigationStateManagerSets the Navigator used with this state manager. The state manager should notify the provided navigator of user-triggered navigation state changes by invokingnavigator.navigateTo(getState()).navigatorparameter value could be null if previously set navigator is destroyed.This method should only be called by a Navigator.
- Specified by:
setNavigatorin interfaceNavigationStateManager
-
getState
public String getState()
Description copied from interface:NavigationStateManagerReturns the current navigation state including view name and any optional parameters.- Specified by:
getStatein interfaceNavigationStateManager- Returns:
- current view and parameter string, not null
-
setState
public void setState(String state)
Description copied from interface:NavigationStateManagerSets 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:
setStatein interfaceNavigationStateManager
-
uriFragmentChanged
public void uriFragmentChanged(Page.UriFragmentChangedEvent event)
Description copied from interface:Page.UriFragmentChangedListenerEvent handler method invoked when the URI fragment of the page changes. Please note that the initial URI fragment has already been set when a new UI is initialized, so there will not be any initial event for listeners added duringUI.init(VaadinRequest).- Specified by:
uriFragmentChangedin interfacePage.UriFragmentChangedListener- Parameters:
event- the URI fragment changed event- See Also:
Page.addUriFragmentChangedListener(UriFragmentChangedListener)
-
getFragment
protected String getFragment()
Returns the current URI fragment tracked by this UriFragentManager.- Returns:
- The URI fragment.
-
setFragment
protected void setFragment(String fragment)
Sets the URI fragment to the given string.- Parameters:
fragment- The new URI fragment.
-
-