mirror of
https://github.com/apache/struts.git
synced 2026-08-31 19:35:40 +00:00
ww-2310 Extra option to make redirectAction supress empty parameters - Apply patch submitted by Dale Newfield
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@612335 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -62,6 +62,9 @@ import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
|
||||
* <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 @@ import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
|
||||
* <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 @@ public class ServletActionRedirectResult extends ServletRedirectResult implement
|
||||
|
||||
/** 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 @@ public class ServletActionRedirectResult extends ServletRedirectResult implement
|
||||
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 @@ public class ServletActionRedirectResult extends ServletRedirectResult implement
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,6 +228,15 @@ public class ServletActionRedirectResult extends ServletRedirectResult implement
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the supressEmptyParameters option
|
||||
*
|
||||
* @param suppress The new value for this option
|
||||
*/
|
||||
public void setSupressEmptyParameters(boolean supressEmptyParameters) {
|
||||
this.supressEmptyParameters = supressEmptyParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a request parameter to be added to the redirect url
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user