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

Issues binding to array of custom editor

    XMLWordPrintable

    Details

      Description

      The Binding model cannot find proper converting property editor when binding to an array of custom type.

      The 'findSpringConvertingPropertyEditor' method of BindingModel finds a TypeDescriptor of types.CustomType[] when perhaps it should be types.CustomType?

      this occurs when trying to bind multiple checkboxes to an array property.

      ex.
      Model:

      public class Model {
         private MyType[] options = {MyType.TYPE_1, MyType.TYPE_2};
         private MyType[] selected;
       
         // getter & setters
      }
      

      View - jsp file

      ....
      <c:forEach items="${model.options}" var="option">
         <form:checkbox path="selected" value="${option}" id="selected${option}" /> <label for="selected${option}"><spring:message message="${option}" /></label>
      </c:forEach>
      

      Notes: The value option prints out the toString() method of the MyType class (because it cannot find the proper converter)
      The same model/jsp and converters bind properly when using the Spring MVC binder.
      The converter works because using a hidden input tag <form:hidden path="oneSelected" /> will bind properly if oneSelected is a field of type MyType.

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            tangp Peter Tang
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: