I fixed the problem with redirect.action. It appears Pat's GD code didn't
take into account parameters getting passed to views. As I wrote it, only
parameters only affect views that are actions.
I added a parameters Map to ViewActionWrapper, and pulled getParams from
the 1.2.1 dist to do the parsing.
diffs attached.
--Erik
8a9,10
> import java.util.Map;
>
12a15
> private Map params;
20c23,29
< // Public --------------------------------------------------------
---
> public ViewActionWrapper(String actionName, Map params)
> {
> this.actionName = actionName;
> this.params = params;
> }
>
> // Public --------------------------------------------------------
24a34,43
>
> public boolean hasParams()
> {
> return params != null;
> }
>
> public Map getParams()
> {
> return params;
> }
diff was unable to work with this file, so here's a description of the change:
import webwork.util.BeanUtil;
at line 133:
while (view instanceof ViewActionWrapper)
{
ViewActionWrapper viewActionWrapper = (ViewActionWrapper)view;
actionName = viewActionWrapper.getActionName();
action = ActionFactory.getAction(actionName);
if(viewActionWrapper.hasParams())
BeanUtil.setProperties(viewActionWrapper.getParams(), action);
try
{
result = action.execute();
12a13,14
> import java.util.*;
>
59a62,71
>
> // The view has parameters
> if (returnView.indexOf(postFix + "?") != -1) {
> try {
> String newActionName = returnView.substring(0,
>returnView.indexOf(postFix + "?"));
> return new ViewActionWrapper(newActionName,
>getParams(returnView));
> } catch (Exception e) {
> // ignore, return normally;
> }
> }
110a123,149
>
> /**
> * Extract parameter map from a string. The map is made
> * from the name value pair after '?'; i.e., ?name1=value&name2=value
> */
> private Map getParams(String candidateAction) {
> if (candidateAction==null) return Collections.EMPTY_MAP;
> try {
> String paramsList =
>candidateAction.substring(candidateAction.indexOf('?')+1);
> StringTokenizer stParams = new StringTokenizer(paramsList, "&");
> Map params = new HashMap();
> while (stParams.hasMoreTokens()) {
> String nameValue = stParams.nextToken();
> StringTokenizer stNameValuePairs = new StringTokenizer(nameValue, "=");
> while (stNameValuePairs.hasMoreTokens()) {
> String name = stNameValuePairs.nextToken();
> String value = stNameValuePairs.nextToken();
> params.put(name, value);
> }
> }
> return params;
> } catch (NoSuchElementException nse) {
> return Collections.EMPTY_MAP;
> } catch (Exception e) {
> return Collections.EMPTY_MAP;
> }
> }