diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/main/java/com/vaadin/navigator/Navigator.java | 13 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/ui/UI.java | 17 |
2 files changed, 18 insertions, 12 deletions
diff --git a/server/src/main/java/com/vaadin/navigator/Navigator.java b/server/src/main/java/com/vaadin/navigator/Navigator.java index 7107f7451d..fc22b19c3b 100644 --- a/server/src/main/java/com/vaadin/navigator/Navigator.java +++ b/server/src/main/java/com/vaadin/navigator/Navigator.java @@ -1272,4 +1272,17 @@ public class Navigator implements Serializable { ui.setNavigator(null); } + /** + * Returns the current navigation state for which the + * {@link #getCurrentView()} has been constructed. This may differ to + * {@link #getState()} in case the URL has been changed on the browser and + * the navigator wasn't yet given an opportunity to construct new view. The + * state is in the form of + * <code>current-view-name/optional/parameters</code> + * + * @return the current navigation state, may be {@code null}. + */ + public String getCurrentNavigationState() { + return currentNavigationState; + } } diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java index 2a3b913e16..e48390666e 100644 --- a/server/src/main/java/com/vaadin/ui/UI.java +++ b/server/src/main/java/com/vaadin/ui/UI.java @@ -31,6 +31,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.concurrent.Future; import java.util.logging.Level; import java.util.logging.Logger; @@ -162,12 +163,6 @@ public abstract class UI extends AbstractSingleComponentContainer this); /** - * Holder for old navigation state, needed in doRefresh in order not to call - * navigateTo too often - */ - private String oldNavigationState; - - /** * Scroll Y position. */ private int scrollTop = 0; @@ -880,12 +875,10 @@ public abstract class UI extends AbstractSingleComponentContainer // PushStateNavigation. Call navigateTo only if state have // truly changed Navigator navigator = getNavigator(); - if (navigator != null) { - if (oldNavigationState == null) oldNavigationState = getNavigator().getState(); - if (!navigator.getState().equals(oldNavigationState)) { - navigator.navigateTo(navigator.getState()); - oldNavigationState = navigator.getState(); - } + if (navigator != null + && !Objects.equals(navigator.getCurrentNavigationState(), + navigator.getState())) { + navigator.navigateTo(navigator.getState()); } } |