Skip to content

Instantly share code, notes, and snippets.

@partkyle
Created August 2, 2011 02:01
Show Gist options
  • Save partkyle/1119440 to your computer and use it in GitHub Desktop.
Save partkyle/1119440 to your computer and use it in GitHub Desktop.
Struts2 Action Redirect Result Builder
public class Redirect {
private String actionName;
private String method;
private Map<String, Object> params = new LinkedHashMap<String, Object>();
public Redirect actionName(String actionName) {
this.actionName = actionName;
return this;
}
public Redirect method(String method) {
this.method = method;
return this;
}
public Redirect param(String key, Object value) {
this.params.put(key, value);
return this;
}
public Result to() {
if (Strings.isEmpty(actionName))
actionName = getActionName();
ServletActionRedirectResult result = new ServletActionRedirectResult(actionName, method);
for (Entry<String, Object> param : params.entrySet()) {
result.addParameter(param.getKey(), param.getValue());
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment