From e80c00ebd8f2c72f197074c4d1192d702539c8d0 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 4 Oct 2012 18:21:03 +0300 Subject: Add Page.getLocation() (#9249) * Send the whole window location, not just fragment, in bootstrap and when the fragment changes * BrowserDetails now has URI getLocation() instead of String getUriFragment() * Keep FragmentChangeListeners as-is, should perhaps change to LocationChangeListeners at some point * Implement Page.getFragment() by means of Page.getLocation() * Differentiate between no fragment (null) and empty fragment ("") as java.net.URI does Change-Id: I1da1ea0664304d0c121a57e85d127fe48605e940 --- client/src/com/vaadin/client/ui/ui/UIConnector.java | 20 ++++++++------------ client/src/com/vaadin/client/ui/ui/VUI.java | 6 +++--- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 3b4e4e1c7c..2a72876924 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -264,21 +264,17 @@ public class UIConnector extends AbstractComponentContainerConnector implements scrollIntoView(connector); } - if (uidl.hasAttribute(UIConstants.FRAGMENT_VARIABLE)) { - getWidget().currentFragment = uidl - .getStringAttribute(UIConstants.FRAGMENT_VARIABLE); + if (uidl.hasAttribute(UIConstants.LOCATION_VARIABLE)) { + String location = uidl + .getStringAttribute(UIConstants.LOCATION_VARIABLE); + int fragmentIndex = location.indexOf('#'); + if (fragmentIndex >= 0) { + getWidget().currentFragment = location + .substring(fragmentIndex + 1); + } if (!getWidget().currentFragment.equals(History.getToken())) { History.newItem(getWidget().currentFragment, true); } - } else { - // Initial request for which the server doesn't yet have a fragment - // (and haven't shown any interest in getting one) - getWidget().currentFragment = History.getToken(); - - // Include current fragment in the next request - client.updateVariable(getWidget().id, - UIConstants.FRAGMENT_VARIABLE, getWidget().currentFragment, - false); } if (firstPaint) { diff --git a/client/src/com/vaadin/client/ui/ui/VUI.java b/client/src/com/vaadin/client/ui/ui/VUI.java index 096b0b60ba..d650b1734c 100644 --- a/client/src/com/vaadin/client/ui/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/ui/VUI.java @@ -128,11 +128,11 @@ public class VUI extends SimplePanel implements ResizeHandler, public void onValueChange(ValueChangeEvent event) { String newFragment = event.getValue(); - // Send the new fragment to the server if it has changed + // Send the location to the server if the fragment has changed if (!newFragment.equals(currentFragment) && connection != null) { currentFragment = newFragment; - connection.updateVariable(id, UIConstants.FRAGMENT_VARIABLE, - newFragment, true); + connection.updateVariable(id, UIConstants.LOCATION_VARIABLE, + Window.Location.getHref(), true); } } }; -- cgit v1.2.3