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

  • Binding a Map

    Hi all!

    Short class descriptions (getters / setters left out):
    Code:
    class Newspaper {
        private Map<String, Price> prices; // Lazy loaded hibernate collection
    &#125;
    class Price &#123;
        private Double dollar;
        private Double euro;
    &#125;
    Binding in jsp (different price for each weekday):
    Code:
    <c&#58;forEach begin="1" end="7" varStatus="loopStatus">
        <spring&#58;bind path="newspaper.prices&#91;$&#123;loopStatus.index&#125;&#93;.dollar">
            <input type="text" name="$&#123;status.expression&#125;" value="$&#123;status.value&#125;"/>
        </spring&#58;bind>
        <spring&#58;bind path="newspaper.prices&#91;$&#123;loopStatus.index&#125;&#93;.euro">
            <input type="text" name="$&#123;status.expression&#125;" value="$&#123;status.value&#125;"/>
        </spring&#58;bind>
    </c&#58;forEach>
    This works if the map contains all keys from 1-7, but how do I handle cases where the map only contains 1-5?
Working...
X