summaryrefslogtreecommitdiffstats
path: root/server
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 /server
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 'server')
-rw-r--r--server/src/com/vaadin/server/BrowserWindowOpener.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/server/src/com/vaadin/server/BrowserWindowOpener.java b/server/src/com/vaadin/server/BrowserWindowOpener.java
index 3ed039887c..3b031d6463 100644
--- a/server/src/com/vaadin/server/BrowserWindowOpener.java
+++ b/server/src/com/vaadin/server/BrowserWindowOpener.java
@@ -16,6 +16,9 @@
package com.vaadin.server;
+import java.util.Collections;
+import java.util.Set;
+
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.ui.BrowserWindowOpenerState;
import com.vaadin.ui.AbstractComponent;
@@ -196,4 +199,108 @@ public class BrowserWindowOpener extends AbstractExtension {
return "popup/" + uiClass.getSimpleName();
}
+ /**
+ * Sets a URI fragment that will be added to the URI opened in the window.
+ * If the window is opened to contain a Vaadin UI, the fragment will be
+ * available using {@link Page#getUriFragment()} on the Page instance of the
+ * new UI.
+ * <p>
+ * The default value is <code>null</code>.
+ *
+ * @param uriFragment
+ * the URI fragment string that should be included in the opened
+ * URI, or <code>null</code> to preserve the original fragment of
+ * the URI.
+ */
+ public void setUriFragment(String uriFragment) {
+ getState().uriFragment = uriFragment;
+ }
+
+ /**
+ * Gets that URI fragment configured for opened windows.
+ *
+ * @return the URI fragment string, or <code>null</code> if no fragment is
+ * configured.
+ *
+ * @see #setUriFragment(String)
+ */
+ public String getUriFragment() {
+ return getState().uriFragment;
+ }
+
+ /**
+ * Sets a parameter that will be added to the query string of the opened
+ * URI. If the window is opened to contain a Vaadin UI, the parameter will
+ * be available using {@link VaadinRequest#getParameter(String)} e.g. using
+ * the request instance passed to {@link UI#init(VaadinRequest)}.
+ * <p>
+ * Setting a parameter with the same name as a previously set parameter will
+ * replace the previous value.
+ *
+ * @param name
+ * the name of the parameter to add, not <code>null</code>
+ * @param value
+ * the value of the parameter to add, not <code>null</code>
+ *
+ * @see #removeParameter(String)
+ * @see #getParameterNames()
+ * @see #getParameter(String)
+ */
+ public void setParameter(String name, String value) {
+ if (name == null || value == null) {
+ throw new IllegalArgumentException("Null not allowed");
+ }
+ getState().parameters.put(name, value);
+ }
+
+ /**
+ * Removes a parameter that has been set using
+ * {@link #setParameter(String, String)}. Removing a parameter that has not
+ * been set has no effect.
+ *
+ * @param name
+ * the name of the parameter to remove, not <code>null</code>
+ *
+ * @see #setParameter(String, String)
+ */
+ public void removeParameter(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Null not allowed");
+ }
+ getState().parameters.remove(name);
+ }
+
+ /**
+ * Gets the names of all parameters set using
+ * {@link #setParameter(String, String)}.
+ *
+ * @return an unmodifiable set of parameter names
+ *
+ * @see #setParameter(String, String)
+ * @see #getParameter(String)
+ */
+ public Set<String> getParameterNames() {
+ return Collections.unmodifiableSet(getState().parameters.keySet());
+ }
+
+ /**
+ * Gets the value of a parameter set using
+ * {@link #setParameter(String, String)}. If there is no parameter with the
+ * given name, <code>null</code> is returned.
+ *
+ * @param name
+ * the name of the parameter to get, not <code>null</code>
+ * @return the value of the parameter, or <code>null</code> there is no
+ * parameter
+ *
+ * @see #setParameter(String, String)
+ * @see #getParameter(String)
+ */
+ public String getParameter(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Null not allowed");
+ }
+ return getState().parameters.get(name);
+ }
+
}