Announcement Announcement Module
Collapse
No announcement yet.
Problems binding a collection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems binding a collection

    Hi,
    OK I give up, I'm stuck ;(

    I have a form command object which has an array (columns). I want to present the values in 'columns' as list of radio buttons. The user then has to select one of the columns. This works fine if they select a radio button, but if they fail to select a value then then I can catch that okt, BUT when the form is redisplayed the column values array is empty. The relevant code I have in the jsp is...

    <c:forEach items="${myForm.columns}"
    var="column"
    varStatus="idx">
    <tr>
    <td>
    <spring:bind path="myForm.columnPos">
    <input type="radio" name="columnPos"
    value='<c:out value="${idx.index}"/>' />
    </spring:bind>
    <spring:bind path="myForm.columns[${idx.index}]">
    <c:out value="${status.value}"/>
    </spring:bind>
    </td>
    </tr>
    </c:forEach>

    How do I get the columns array to keep its values if the form submission fails in the formvalidator?

  • #2
    OK, I solved it

    <c:forEach items="${myForm.columns}"
    var="column"
    varStatus="idx">
    <tr>
    <td>
    <spring:bind path="myForm.columnPos">
    <input type="radio" name="columnPos"
    value='<c:out value="${idx.index}"/>' />
    </spring:bind>
    <spring:bind path="myForm.columns[${idx.index}]">

    //THIS seems to have done the trick
    <input type="hidden" name="columns" value="${status.value}"/>"
    //////////////////
    <c:out value="${status.value}"/>
    </spring:bind>
    </td>
    </tr>
    </c:forEach>

    Comment

    Working...
    X