Skip to content

Commit

Permalink
WW-3714 Update StrutsResultSupport to allow overriding new signature
Browse files Browse the repository at this point in the history
  • Loading branch information
kusalk committed Oct 22, 2024
1 parent 5eaeaf9 commit 8ff8d18
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public StrutsResultSupport(String location, boolean parse, boolean encode) {
public void setLocation(String location) {
this.location = location;
}

/**
* Gets the location it was created with, mainly for testing
*
Expand Down Expand Up @@ -201,9 +201,10 @@ public void setEncode(boolean encode) {
* @param invocation the execution state of the action.
* @throws Exception if an error occurs while executing the result.
*/
@Override
public void execute(ActionInvocation invocation) throws Exception {
lastFinalLocation = parseLocation ? conditionalParse(location, invocation) : location;
doExecute(lastFinalLocation, invocation);
doExecute(lastFinalLocation, (org.apache.struts2.ActionInvocation) invocation);
}

/**
Expand All @@ -216,7 +217,7 @@ public void execute(ActionInvocation invocation) throws Exception {
protected String conditionalParse(String param, ActionInvocation invocation) {
if (parse && param != null && invocation != null) {
return TextParseUtil.translateVariables(
param,
param,
invocation.getStack(),
new EncodingParsedValueEvaluator());
} else {
Expand All @@ -228,7 +229,7 @@ protected String conditionalParse(String param, ActionInvocation invocation) {
* As {@link #conditionalParse(String, ActionInvocation)} but does not
* convert found object into String. If found object is a collection it is
* returned if found object is not a collection it is wrapped in one.
*
*
* @param param parameter
* @param invocation action invocation
* @param excludeEmptyElements 'true' for excluding empty elements
Expand All @@ -237,7 +238,7 @@ protected String conditionalParse(String param, ActionInvocation invocation) {
protected Collection<String> conditionalParseCollection(String param, ActionInvocation invocation, boolean excludeEmptyElements) {
if (parse && param != null && invocation != null) {
return TextParseUtil.translateVariablesCollection(
param,
param,
invocation.getStack(),
excludeEmptyElements,
new EncodingParsedValueEvaluator());
Expand All @@ -251,9 +252,10 @@ protected Collection<String> conditionalParseCollection(String param, ActionInvo
/**
* {@link com.opensymphony.xwork2.util.TextParseUtil.ParsedValueEvaluator} to do URL encoding for found values. To be
* used for single strings or collections.
*
*
*/
private final class EncodingParsedValueEvaluator implements TextParseUtil.ParsedValueEvaluator {
@Override
public Object evaluate(String parsedValue) {
if (encode) {
if (parsedValue != null) {
Expand All @@ -269,6 +271,13 @@ public Object evaluate(String parsedValue) {
}
}

/**
* @deprecated since 6.7.0, override {@link #doExecute(String, org.apache.struts2.ActionInvocation)} instead.
*/
@Deprecated
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
}

/**
* Executes the result given a final location (jsp page, action, etc) and the action invocation
* (the state in which the action was executed). Subclasses must implement this class to handle
Expand All @@ -278,5 +287,7 @@ public Object evaluate(String parsedValue) {
* @param invocation the execution state of the action.
* @throws Exception if an error occurs while executing the result.
*/
protected abstract void doExecute(String finalLocation, ActionInvocation invocation) throws Exception;
protected void doExecute(String finalLocation, org.apache.struts2.ActionInvocation invocation) throws Exception {
doExecute(finalLocation, ActionInvocation.adapt(invocation));
}
}

0 comments on commit 8ff8d18

Please sign in to comment.