You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2008/01/16 03:30:23 UTC
svn commit: r612335 -
/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
Author: husted
Date: Tue Jan 15 18:30:21 2008
New Revision: 612335
URL: http://svn.apache.org/viewvc?rev=612335&view=rev
Log:
ww-2310 Extra option to make redirectAction supress empty parameters - Apply patch submitted by Dale Newfield
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java?rev=612335&r1=612334&r2=612335&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java Tue Jan 15 18:30:21 2008
@@ -62,6 +62,9 @@
* <li><b>namespace</b> - used to determine which namespace the action is in that we're redirecting to . If namespace is
* null, this defaults to the current namespace</li>
*
+ * <li><b>supressEmptyParameters</b> - optional boolean (defaults to false) that can prevent parameters with no values
+ * from being included in the redirect URL.</li>
+ *
* </ul>
*
* <!-- END SNIPPET: params -->
@@ -104,6 +107,8 @@
* <param name="reportType">pie</param>
* <param name="width">100</param>
* <param name="height">100</param>
+ * <param name="empty"></param>
+ * <param name="supressEmptyParameters">true</param>
* </result>
* </action>
* </package>
@@ -119,12 +124,13 @@
/** The default parameter */
public static final String DEFAULT_PARAM = "actionName";
-
+
private static final Logger LOG = LoggerFactory.getLogger(ServletActionRedirectResult.class);
protected String actionName;
protected String namespace;
protected String method;
+ protected boolean supressEmptyParameters = false;
private Map<String, String> requestParameters = new LinkedHashMap<String, String>();
@@ -146,10 +152,10 @@
this.actionName = actionName;
this.method = method;
}
-
+
protected List<String> prohibitedResultParam = Arrays.asList(new String[] {
DEFAULT_PARAM, "namespace", "method", "encode", "parse", "location",
- "prependServletContext" });
+ "prependServletContext", "supressEmptyParameters" });
/**
* @see com.opensymphony.xwork2.Result#execute(com.opensymphony.xwork2.ActionInvocation)
@@ -179,6 +185,10 @@
requestParameters.put(e.getKey().toString(),
e.getValue() == null ? "":
conditionalParse(e.getValue().toString(), invocation));
+ String potentialValue = e.getValue() == null ? "": conditionalParse(e.getValue().toString(), invocation);
+ if (!supressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) {
+ requestParameters.put(e.getKey().toString(), potentialValue);
+ }
}
}
}
@@ -216,6 +226,15 @@
*/
public void setMethod(String method) {
this.method = method;
+ }
+
+ /**
+ * Sets the supressEmptyParameters option
+ *
+ * @param suppress The new value for this option
+ */
+ public void setSupressEmptyParameters(boolean supressEmptyParameters) {
+ this.supressEmptyParameters = supressEmptyParameters;
}
/**