diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java index 3a366203..ac75fbb2 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java @@ -52,6 +52,7 @@ import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.util.WebUtils; import org.springframework.webflow.core.collection.ParameterMap; import org.springframework.webflow.definition.TransitionDefinition; @@ -477,10 +478,13 @@ public abstract class AbstractMvcView implements View { } public Object execute(Object source, Object context) throws ConversionExecutionException { - if (!(source instanceof String)) { + if (source instanceof MultipartFile) { // for the case of MultipartFile parameters; nothing to do return source; } + if (source instanceof String[]) { + return source; + } String formattedValue = (String) source; DefaultMappingContext mappingContext = (DefaultMappingContext) context; Expression target = mappingContext.getCurrentMapping().getTargetExpression(); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java index b64cfccc..45262edd 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java @@ -1,6 +1,5 @@ package org.springframework.webflow.mvc.portlet; -import java.util.Date; import java.util.Locale; import javax.portlet.RenderRequest; @@ -26,7 +25,7 @@ public class PortletMvcViewTests extends TestCase { protected void setUp() { DateFormatter dateFormatter = new DateFormatter(); dateFormatter.setLocale(Locale.ENGLISH); - formatterRegistry.registerFormatter(Date.class, dateFormatter); + formatterRegistry.registerFormatter(dateFormatter); } public void testRender() throws Exception { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java index b5e22ed2..953f8434 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java @@ -18,7 +18,6 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; import org.springframework.validation.BindingResult; import org.springframework.web.servlet.View; -import org.springframework.webflow.mvc.servlet.ServletMvcView; import org.springframework.webflow.mvc.view.AbstractMvcView; import org.springframework.webflow.test.MockFlowExecutionKey; import org.springframework.webflow.test.MockRequestContext; @@ -34,7 +33,7 @@ public class ServletMvcViewTests extends TestCase { protected void setUp() { DateFormatter dateFormatter = new DateFormatter(); dateFormatter.setLocale(Locale.ENGLISH); - formatterRegistry.registerFormatter(Date.class, dateFormatter); + formatterRegistry.registerFormatter(dateFormatter); } public void testRender() throws Exception { 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 9dd3da98..6179c893 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 @@ -4,6 +4,7 @@ import java.security.Principal; import java.util.Calendar; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Locale; import java.util.Map; @@ -42,7 +43,7 @@ public class MvcViewTests extends TestCase { protected void setUp() { DateFormatter dateFormatter = new DateFormatter(); dateFormatter.setLocale(Locale.ENGLISH); - formatterRegistry.registerFormatter(Date.class, dateFormatter); + formatterRegistry.registerFormatter(dateFormatter); } public void testRender() throws Exception { @@ -164,6 +165,10 @@ public class MvcViewTests extends TestCase { context.putRequestParameter("dateProperty", "2007-01-01"); context.putRequestParameter("beanProperty.name", "foo"); context.putRequestParameter("multipartFile", new MockMultipartFile("foo", new byte[0])); + // context.putRequestParameter("stringArrayProperty", new String[] { "foo", "bar", "baz" }); + // context.putRequestParameter("integerArrayProperty", new String[] { "1", "2", "3" }); + // context.putRequestParameter("primitiveArrayProperty", new String[] { "1", "2", "3" }); + // context.putRequestParameter("listProperty", new String[] { "1", "2", "3" }); BindBean bindBean = new BindBean(); StaticExpression modelObject = new StaticExpression(bindBean); modelObject.setExpressionString("bindBean"); @@ -187,6 +192,22 @@ public class MvcViewTests extends TestCase { assertEquals(cal.getTime(), bindBean.getDateProperty()); assertEquals("foo", bindBean.getBeanProperty().getName()); assertEquals("foo", bindBean.getMultipartFile().getName()); + // assertEquals(3, bindBean.getStringArrayProperty().length); + // assertEquals("foo", bindBean.getStringArrayProperty()[0]); + // assertEquals("bar", bindBean.getStringArrayProperty()[1]); + // assertEquals("baz", bindBean.getStringArrayProperty()[2]); + // assertEquals(3, bindBean.getIntegerArrayProperty().length); + // assertEquals(new Integer(1), bindBean.getIntegerArrayProperty()[0]); + // assertEquals(new Integer(2), bindBean.getIntegerArrayProperty()[1]); + // assertEquals(new Integer(3), bindBean.getIntegerArrayProperty()[2]); + // assertEquals(3, bindBean.getPrimitiveArrayProperty().length); + // assertEquals(1, bindBean.getPrimitiveArrayProperty()[0]); + // assertEquals(2, bindBean.getPrimitiveArrayProperty()[1]); + // assertEquals(3, bindBean.getPrimitiveArrayProperty()[2]); + // assertEquals(3, bindBean.getListProperty().size()); + // assertEquals(new Integer(1), bindBean.getListProperty().get(0)); + // assertEquals(new Integer(2), bindBean.getListProperty().get(1)); + // assertEquals(new Integer(3), bindBean.getListProperty().get(2)); } public void testResumeEventModelBindingAllowedFields() throws Exception { @@ -301,6 +322,12 @@ public class MvcViewTests extends TestCase { private NestedBean beanProperty; private MultipartFile multipartFile; + private String[] stringArrayProperty; + private Integer[] integerArrayProperty; + private int[] primitiveArrayProperty; + private List listProperty; + private Map mapProperty; + public BindBean() { Calendar cal = Calendar.getInstance(); cal.clear(); @@ -352,6 +379,51 @@ public class MvcViewTests extends TestCase { public void setMultipartFile(MultipartFile multipartFile) { this.multipartFile = multipartFile; } + + public String[] getStringArrayProperty() { + return stringArrayProperty; + } + + public void setStringArrayProperty(String[] stringArrayProperty) { + this.stringArrayProperty = stringArrayProperty; + } + + public Integer[] getIntegerArrayProperty() { + return integerArrayProperty; + } + + public void setIntegerArrayProperty(Integer[] integerArrayProperty) { + this.integerArrayProperty = integerArrayProperty; + } + + public int[] getPrimitiveArrayProperty() { + return primitiveArrayProperty; + } + + public void setPrimitiveArrayProperty(int[] primitiveArrayProperty) { + this.primitiveArrayProperty = primitiveArrayProperty; + } + + public List getListProperty() { + return listProperty; + } + + public void setListProperty(List listProperty) { + this.listProperty = listProperty; + } + + public Map getMapProperty() { + return mapProperty; + } + + public void setMapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + } + + public void setBeanProperty(NestedBean beanProperty) { + this.beanProperty = beanProperty; + } + } public static class NestedBean {