Announcement Announcement Module
Collapse
No announcement yet.
Binding with a Map<String,List<Object>> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding with a Map<String,List<Object>>

    I have an map, and an array containing the keys to the map in my formBackingObject:

    Code:
    private SortedMap<String, List<MyObject1>> myMap = 
         new TreeMap<String, List<MyObject1>>;
    
    private List<String> keys;
    and I am trying dynamically generate a bound list of input boxes like:

    HTML Code:
    <c:forEach var="key" items="${myForm.keys}">    
      <tr>
        <td>
          <table>
            <tbody>
              <c:forEach items="myForm.myMap[${keys.key}]" 
                         var="mapVar" varStatus="rowStatus">
                <tr>
                  <td>                 
                    <spring:bind path="myForm.myMap[${keys.key}]}">
                      <input name="<c:out value="${status.expression}"/>" type="text" 
                             value="<c:out value="${status.value.lot}"/>"/>
                    </spring:bind>
                  </td>
                  <td>
                    <spring:bind path="myForm.myMap[${keys.key}]">
                      <input name="<c:out value="${status.expression}"/>" type="text" 
                             value="<c:out value="${status.value.quantity}"/>"/>
                    </spring:bind>
                  </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
        </td>
      </tr>
    </c:forEach>
    This is however not working It's because I am not indexing the list inside the myMap

    I have also tried:

    HTML Code:
    <spring:bind path="myForm.myMap[${keys.key}][${rowStatus.index}]">
                      <input name="<c:out value="${status.expression}"/>" type="text" 
                             value="<c:out value="${status.value.quantity}"/>"/>
     </spring:bind>
    and that doesn't work either. Can anyone advice me on how to bind to two dimensional arrays like this?

    -Ed

  • #2
    This is a good tutorial that can help you: http://mattfleming.com/node/134

    On a side note what is the generated html for the above spring bind.

    Comment

    Working...
    X