Skip to content

Commit

Permalink
WW-4068 Extracts method to accept parameter names to allow easier ove…
Browse files Browse the repository at this point in the history
…rriding

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1483950 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
lukaszlenart committed May 17, 2013
1 parent 7caf810 commit 294d380
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ protected void addParametersToContext(ActionContext ac, Map<String, Object> newP
}

protected void setParameters(Object action, ValueStack stack, final Map<String, Object> parameters) {
ParameterNameAware parameterNameAware = (action instanceof ParameterNameAware)
? (ParameterNameAware) action : null;

Map<String, Object> params;
Map<String, Object> acceptableParameters;
if (ordered) {
Expand All @@ -289,11 +286,7 @@ protected void setParameters(Object action, ValueStack stack, final Map<String,

for (Map.Entry<String, Object> entry : params.entrySet()) {
String name = entry.getKey();

boolean acceptableName = acceptableName(name)
|| (parameterNameAware != null && parameterNameAware.acceptableParameterName(name));

if (acceptableName) {
if (isAcceptableParameter(name, action)) {
acceptableParameters.put(name, entry.getValue());
}
}
Expand Down Expand Up @@ -346,6 +339,18 @@ protected void setParameters(Object action, ValueStack stack, final Map<String,
addParametersToContext(ActionContext.getContext(), acceptableParameters);
}

/**
* Checks if name of parameter can be accepted or thrown away
*
* @param name parameter name
* @param action current action
* @return true if parameter is accepted
*/
protected boolean isAcceptableParameter(String name, Object action) {
ParameterNameAware parameterNameAware = (action instanceof ParameterNameAware) ? (ParameterNameAware) action : null;
return acceptableName(name) || (parameterNameAware != null && parameterNameAware.acceptableParameterName(name));
}

/**
* Gets an instance of the comparator to use for the ordered sorting. Override this
* method to customize the ordering of the parameters as they are set to the
Expand Down

0 comments on commit 294d380

Please sign in to comment.