request param bug fix

This commit is contained in:
Keith Donald
2008-03-16 21:43:40 +00:00
parent 3ef868a0e9
commit e12104689b
3 changed files with 34 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ package org.springframework.webflow.mvc;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -154,7 +155,20 @@ public class FlowController extends AbstractController {
}
protected MutableAttributeMap defaultFlowExecutionInputMap(HttpServletRequest request) {
return new LocalAttributeMap(request.getParameterMap());
LocalAttributeMap inputMap = new LocalAttributeMap();
Map parameterMap = request.getParameterMap();
Iterator it = parameterMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String name = (String) entry.getKey();
String[] values = (String[]) entry.getValue();
if (values.length == 1) {
inputMap.put(name, values[0]);
} else {
inputMap.put(name, values);
}
}
return inputMap;
}
protected ModelAndView defaultHandleFlowOutcome(String flowId, String outcome, AttributeMap endedOutput,

View File

@@ -16,6 +16,8 @@
package org.springframework.webflow.mvc;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -139,7 +141,20 @@ public class FlowHandlerAdapter extends WebApplicationObjectSupport implements H
}
protected MutableAttributeMap defaultFlowExecutionInputMap(HttpServletRequest request) {
return new LocalAttributeMap(request.getParameterMap());
LocalAttributeMap inputMap = new LocalAttributeMap();
Map parameterMap = request.getParameterMap();
Iterator it = parameterMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String name = (String) entry.getKey();
String[] values = (String[]) entry.getValue();
if (values.length == 1) {
inputMap.put(name, values[0]);
} else {
inputMap.put(name, values);
}
}
return inputMap;
}
protected ModelAndView defaultHandleFlowOutcome(String flowId, String outcome, AttributeMap endedOutput,

View File

@@ -179,7 +179,9 @@ public class FlowControllerTests extends TestCase {
request.addParameter("ajaxSource", "this");
context.setAjaxRequest(true);
context.requestFlowExecutionRedirect();
executor.launchExecution("foo", new LocalAttributeMap(request.getParameterMap()), context);
LocalAttributeMap inputMap = new LocalAttributeMap();
inputMap.put("ajaxSource", "this");
executor.launchExecution("foo", inputMap, context);
FlowExecutionResult result = FlowExecutionResult.createPausedResult("foo", "12345");
EasyMock.expectLastCall().andReturn(result);
EasyMock.replay(new Object[] { executor });