CLK-779
git-svn-id: https://svn.apache.org/repos/asf/click/trunk/click@1197501 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extras/src/org/apache/click/extras/control/PageSubmit.java b/extras/src/org/apache/click/extras/control/PageSubmit.java
index c1c2099..e5e31c1 100644
--- a/extras/src/org/apache/click/extras/control/PageSubmit.java
+++ b/extras/src/org/apache/click/extras/control/PageSubmit.java
@@ -18,6 +18,8 @@
*/
package org.apache.click.extras.control;
+import java.util.Map;
+
import org.apache.click.Page;
import org.apache.click.control.Submit;
import org.apache.click.util.ClickUtils;
@@ -58,6 +60,9 @@
/** The target page to redirect to. */
protected Class<? extends Page> pageClass;
+ /** The map of URL request parameters. */
+ protected Map<String, ?> params;
+
// ----------------------------------------------------------- Constructors
/**
@@ -97,6 +102,21 @@
}
/**
+ * Create a PageSubmit button with the given name, target pageClass and request parameters.
+ *
+ * @param name the button name
+ * @param pageClass the target page class
+ * @param params the URL redirect parameters
+ */
+ public PageSubmit(String name, Class<? extends Page> pageClass, Map<String, ?> params) {
+ super(name);
+
+ setPageClass(pageClass);
+ setListener(this, "onClick");
+ this.params = params;
+ }
+
+ /**
* Create a PageSubmit button with the given name, label and target
* pageClass.
*
@@ -112,6 +132,23 @@
}
/**
+ * Create a PageSubmit button with the given name, label, target and request parameters.
+ * pageClass.
+ *
+ * @param name the button name
+ * @param label the button display label
+ * @param pageClass the target page class
+ * @param params the URL redirect request parameters
+ */
+ public PageSubmit(String name, String label, Class<? extends Page> pageClass, Map<String, ?> params) {
+ super(name, label);
+
+ setPageClass(pageClass);
+ setListener(this, "onClick");
+ this.params = params;
+ }
+
+ /**
* Create an PageSubmit button with no name or target page class
* defined.
* <p/>
@@ -162,7 +199,11 @@
if (pageClass == null) {
throw new RuntimeException("target pageClass is not defined");
}
- page.setRedirect(pageClass);
+ if (params != null) {
+ page.setRedirect(pageClass, params);
+ } else {
+ page.setRedirect(pageClass);
+ }
return false;
}