diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-10-04 18:21:03 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-10-05 14:10:03 +0300 |
commit | e80c00ebd8f2c72f197074c4d1192d702539c8d0 (patch) | |
tree | a955befdc9e7fa65bd80467256b7b1318823657a /client | |
parent | ff4ee18e0f26515cfa818ab9d249932a3bbf0955 (diff) | |
download | vaadin-framework-e80c00ebd8f2c72f197074c4d1192d702539c8d0.tar.gz vaadin-framework-e80c00ebd8f2c72f197074c4d1192d702539c8d0.zip |
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
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/ui/UIConnector.java | 20 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/ui/VUI.java | 6 |
2 files changed, 11 insertions, 15 deletions
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<String> 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); } } }; |