hi everybody.
i am using swf-2.0.1.CI-477. when i perform databinding from a multipart/form-data encoded form containing a <input type="file"/> element (aka fileupload) to a modelbean, i get the following expception.
somehow the CommonsMultipartFile object finds its way into the LocalParameterMap, where only String based values are expected.Code:java.lang.IllegalArgumentException: Map key 'attachment' has value [org.springframework.web.multipart.commons.CommonsMultipartFile@2002cfa5] that is not of expected type [class java.lang.String], instead it is of type [org.springframework.web.multipart.commons.CommonsMultipartFile] at org.springframework.binding.collection.MapAccessor.assertKeyValueInstanceOf(MapAccessor.java:421) at org.springframework.webflow.core.collection.LocalParameterMap.get(LocalParameterMap.java:133) at org.springframework.webflow.core.collection.LocalParameterMap.get(LocalParameterMap.java:113) at org.springframework.webflow.mvc.view.AbstractMvcView$RequestParameterExpression.getValue(AbstractMvcView.java:450) at org.springframework.binding.mapping.impl.DefaultMapping.map(DefaultMapping.java:113) at org.springframework.binding.mapping.impl.DefaultMapper.map(DefaultMapper.java:87) at org.springframework.webflow.mvc.view.AbstractMvcView.bind(AbstractMvcView.java:287) at org.springframework.webflow.mvc.view.AbstractMvcView.processUserEvent(AbstractMvcView.java:184) at org.springframework.webflow.engine.ViewState.resume(ViewState.java:187) at org.springframework.webflow.engine.Flow.resume(Flow.java:535) at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:261)
after browsing the code, i think i might have found a clue where this happens. the class org.springframework.webflow.context.servlet.Servle tExternalContext creates in its init method a LocalParameterMap with a HttpServletRequestParameterMap based on a request which might be a DefaultMultipartHttpServletRequest object.
the HttpServletRequestParameterMap class implements special handling for MultipartHttpServletRequest in its getAttribute(String key) method, extracting entries from the fileMap as well.Code:this.requestParameterMap = new LocalParameterMap(new HttpServletRequestParameterMap(request)); // request might a DefaultMultipartHttpServletRequest
once in the LocalParameterMap, databinding fails due to the strict type checking in the MapAccessor.assertKeyValueInstanceOf method.Code:if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Object data = multipartRequest.getFileMap().get(key); if (data != null) { return data; } }
might this behaviour be a bug or is this kind of databinding not supported?
best regards
gerd oberlechner


Reply With Quote