diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-10-05 13:29:25 +0300 |
---|---|---|
committer | Denis Anisimov <denis@vaadin.com> | 2015-11-07 10:47:23 +0200 |
commit | d18d2fb7edd7901bab603bbce02d561808300ab3 (patch) | |
tree | 1009e8d830e43ab9a45f1bfd6288417bde158d0f /server/src/com/vaadin/navigator | |
parent | 9c1908d0a5fdba09167414e837cc08a2f746584b (diff) | |
download | vaadin-framework-d18d2fb7edd7901bab603bbce02d561808300ab3.tar.gz vaadin-framework-d18d2fb7edd7901bab603bbce02d561808300ab3.zip |
Add destroy method for Navigator (#10213).
Change-Id: Icb2676bd603bbe36a8d7d005128036234a5a0c62
Diffstat (limited to 'server/src/com/vaadin/navigator')
-rw-r--r-- | server/src/com/vaadin/navigator/NavigationStateManager.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/navigator/Navigator.java | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/server/src/com/vaadin/navigator/NavigationStateManager.java b/server/src/com/vaadin/navigator/NavigationStateManager.java index d454d044cb..3e9c54c961 100644 --- a/server/src/com/vaadin/navigator/NavigationStateManager.java +++ b/server/src/com/vaadin/navigator/NavigationStateManager.java @@ -56,6 +56,8 @@ public interface NavigationStateManager extends Serializable { * Sets the Navigator used with this state manager. The state manager should * notify the provided navigator of user-triggered navigation state changes * by invoking <code>navigator.navigateTo(getState())</code>. + * {@code navigator} parameter value could be null if previously set + * navigator is destroyed. * <p> * This method should only be called by a Navigator. */ diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index fa587a2eaa..82e8de920a 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -113,11 +113,15 @@ public class Navigator implements Serializable { */ public UriFragmentManager(Page page) { this.page = page; - page.addUriFragmentChangedListener(this); } @Override public void setNavigator(Navigator navigator) { + if (this.navigator == null && navigator != null) { + page.addUriFragmentChangedListener(this); + } else if (this.navigator != null && navigator == null) { + page.removeUriFragmentChangedListener(this); + } this.navigator = navigator; } @@ -980,4 +984,13 @@ public class Navigator implements Serializable { public void removeViewChangeListener(ViewChangeListener listener) { listeners.remove(listener); } + + /** + * Destroys the navigator and cleans it up. The method detaches the + * navigator from UI and removes all view change listeners. + */ + public void destroy() { + stateManager.setNavigator(null); + ui.setNavigator(null); + } } |