Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: 2.1.1
-
Fix Version/s: 2.2.0.RC1
-
Component/s: Binding: Expression Language Support
-
Labels:None
-
Reference URL:
Description
Given this code:
public class Survey {
private Map<Question, Response> responses = new HashMap<Question,Response>();
...
}
public class QuestionConverter implements Converter<Integer, Question> {
...
}
<form:input path="responses[1].value" />
During rendering, the expression "responses[1].value" is processed correctly by Spring EL, which converts the integer 1 to a Question, then does a look up in the responses map, and then converts the "value" field to a String. At this point this should be all that is needed. However, the following exception occurs:
java.lang.IllegalArgumentException: The field type is required
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.webflow.mvc.view.ConvertingPropertyEditorAdapter.<init>(ConvertingPropertyEditorAdapter.java:48)
at org.springframework.webflow.mvc.view.BindingModel.findSpringConvertingPropertyEditor(BindingModel.java:273)
at org.springframework.webflow.mvc.view.BindingModel.findEditor(BindingModel.java:183)
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:125)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)
Spring MVC's BindStatus tries to find a PropertyEditor but the above expression cannot be processed by the BeanWrapperImpl because it fails to recognize that 1 needs to be converted to a Question.
It would be safe if we didn't create a ProperytEditor when the BeanWrapperImpl fails as Spring EL has already formatted the value correctly.