diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java index c72cb7f6..68bfb884 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import org.springframework.beans.factory.BeanFactory; -import org.springframework.binding.collection.MapAdaptable; import org.springframework.binding.convert.ConversionException; import org.springframework.binding.convert.ConversionExecutor; import org.springframework.binding.expression.EvaluationException; @@ -237,8 +236,7 @@ public abstract class MvcView implements View { private void addDefaultMappings(DefaultMapper mapper, ParameterMap requestParameters, Object model) { for (Iterator it = requestParameters.asMap().keySet().iterator(); it.hasNext();) { String name = (String) it.next(); - Expression source = expressionParser.parseExpression(name, new FluentParserContext() - .evaluate(MapAdaptable.class)); + Expression source = new RequestParameterExpression(name); Expression target = expressionParser.parseExpression(name, new FluentParserContext().evaluate(model .getClass())); DefaultMapping mapping = new DefaultMapping(source, target); @@ -360,6 +358,33 @@ public abstract class MvcView implements View { } } + private static class RequestParameterExpression implements Expression { + + private String parameterName; + + public RequestParameterExpression(String parameterName) { + this.parameterName = parameterName; + } + + public String getExpressionString() { + return parameterName; + } + + public Object getValue(Object context) throws EvaluationException { + ParameterMap map = (ParameterMap) context; + return map.get(parameterName); + } + + public Class getValueType(Object context) { + return String.class; + } + + public void setValue(Object context, Object value) throws EvaluationException { + throw new UnsupportedOperationException("Not supported"); + } + + } + private static class FormatterBackedMappingConversionExecutor implements ConversionExecutor { private FormatterRegistry formatterRegistry; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java index e8ffc99d..bf1ef615 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java @@ -127,6 +127,7 @@ public class MvcViewTests extends TestCase { context.putRequestParameter("stringProperty", "foo"); context.putRequestParameter("integerProperty", "5"); context.putRequestParameter("dateProperty", "2007-01-01"); + context.putRequestParameter("beanProperty.name", "foo"); BindBean bindBean = new BindBean(); StaticExpression modelObject = new StaticExpression(bindBean); modelObject.setExpressionString("bindBean"); @@ -148,6 +149,7 @@ public class MvcViewTests extends TestCase { cal.clear(); cal.set(Calendar.YEAR, 2007); assertEquals(cal.getTime(), bindBean.getDateProperty()); + assertEquals("foo", bindBean.getBeanProperty().getName()); } private class MockMvcView extends MvcView { @@ -180,12 +182,14 @@ public class MvcViewTests extends TestCase { private String stringProperty; private Integer integerProperty = new Integer(3); private Date dateProperty; + private NestedBean beanProperty; public BindBean() { Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(Calendar.YEAR, 2008); dateProperty = cal.getTime(); + beanProperty = new NestedBean(); } public String getStringProperty() { @@ -212,6 +216,21 @@ public class MvcViewTests extends TestCase { this.dateProperty = dateProperty; } + public NestedBean getBeanProperty() { + return beanProperty; + } + } + + public static class NestedBean { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } }