summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-11-29 14:39:51 +0200
committerLeif Åstrand <leif@vaadin.com>2012-11-29 14:39:51 +0200
commit5ed529dfe9ce6f81975cb1072aaca974e63e4b26 (patch)
tree12a1b8096742631642be9c9739fb7239be4c0a42 /client
parentc4e6e44dde9c107c231422e48322805b50a09d05 (diff)
downloadvaadin-framework-5ed529dfe9ce6f81975cb1072aaca974e63e4b26.tar.gz
vaadin-framework-5ed529dfe9ce6f81975cb1072aaca974e63e4b26.zip
Add fragment and parameter support to BrowserWindowOpener (#10093)
Change-Id: I32577503ae4d85c80579f9544cdb61ab9788ef23
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java b/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java
index 63915af1bd..4222ec5418 100644
--- a/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java
+++ b/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java
@@ -16,10 +16,14 @@
package com.vaadin.client.extensions;
+import java.util.Map.Entry;
+
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
import com.vaadin.server.BrowserWindowOpener;
@@ -51,8 +55,41 @@ public class BrowserWindowOpenerConnector extends AbstractExtensionConnector
@Override
public void onClick(ClickEvent event) {
String url = getResourceUrl(BrowserWindowOpenerState.locationResource);
+ url = addParmatersAndFragment(url);
if (url != null) {
Window.open(url, getState().target, getState().features);
}
}
+
+ private String addParmatersAndFragment(String url) {
+ if (url == null) {
+ return null;
+ }
+
+ if (!getState().parameters.isEmpty()) {
+ StringBuilder params = new StringBuilder();
+ for (Entry<String, String> entry : getState().parameters.entrySet()) {
+ if (params.length() != 0) {
+ params.append('&');
+ }
+ params.append(URL.encodeQueryString(entry.getKey()));
+ params.append('=');
+
+ String value = entry.getValue();
+ if (value != null) {
+ params.append(URL.encodeQueryString(value));
+ }
+ }
+
+ url = ApplicationConnection
+ .addGetParameters(url, params.toString());
+ }
+
+ if (getState().uriFragment != null) {
+ // Replace previous fragment or just add to the end of the url
+ url = url.replaceFirst("#.*|$", "#" + getState().uriFragment);
+ }
+
+ return url;
+ }
}