Announcement Announcement Module
Collapse
No announcement yet.
Command Object Binding with Sets Issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Command Object Binding with Sets Issue

    I have a command object of my own class type Encounter. Encounter has a method getObs that returns a set of observations. I want my form to display fields for each of these observations. For instance, right now there is a height observation and a weight observation in the command object.

    The issue is that Sets are not ordered so sometimes height is the first field and sometimes weight. That isn't a huge deal but the name of each field is gotten in EL using ${obs.concept.name} and half the time the obs that says it is weight is actually bound to the height and the height to the weight so the user fills in the values and they are swapped when the command object is saved in the controller.

    Inside a for each loop, I would assume that ${obs.concept.name} and <form:input path="obs[${status.index}].valueNumeric" /> would refer to the same object but this doesn't seem to be the case.

    Does anyone have any idea what to do??? Please help. I am pulling out my hair. My code is below.

    Thanks in advance,

    Rita


    <c:forEach items="${growthEncounter.obs}" varStatus="status" var="obs">

    <tr>
    <td colspan="2">${obs.concept.name}</td>
    </tr>
    <tr>
    <td>Value Numeric:</td>
    <td><form:input path="obs[${status.index}].valueNumeric" /></td>
    <td><form:errors path="obs[${status.index}].valueNumeric" cssClass="error" /></td>
    </tr>
    <tr>
    <td colspan="2"><spring:bind path="obs[${status.index}].location">
    <input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}" />
    </spring:bind></td>
    </tr>
    <tr>
    <td colspan="2"><spring:bind path="obs[${status.index}].obsDatetime">
    <input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}" />
    </spring:bind></td>
    </tr>
    </c:forEach>

  • #2
    use [ code][/code ] tags when posting code, next to that use the search as this question has been anwsered numerous times before.

    Short answer: You can only bind to indexed collections, Set isn't indexed.

    Comment

    Working...
    X