Uploaded image for project: 'Spring Web Flow'
  1. Spring Web Flow
  2. SWF-1370

IllegalArgumentException in ConvertingPropertyEditorAdapter due to invalid BeanWrapper expression

    XMLWordPrintable

    Details

      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.

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            rstoya05-aop Rossen Stoyanchev
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: