Created
August 2, 2011 02:01
-
-
Save partkyle/1119440 to your computer and use it in GitHub Desktop.
Struts2 Action Redirect Result Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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