PDA

View Full Version : Display


JohnDew
Sep 10th, 2007, 07:08 AM
Hi ,
I have one more problem with display using jstl in Spring.
My Case.java has Bills of type Set.
Bill.java has BilledServices of type List.
BilledServices.java is a class.
Now I want to display field data within BilledServices. How do I do that?

command object has case object.

jglynn
Sep 10th, 2007, 09:33 AM
<c:forEach var="bill" items="${command.bills}" varStatus="loopStatus1">
<c:forEach items="${bill.billedServices}" varStatus="loopStatus2">

<form:input path="bills[${loopStatus1.index}].billedServices[${loopStatus2.index}.fieldName"/>

</c:forEach>
</c:forEach>

JohnDew
Sep 11th, 2007, 01:12 AM
Hi jglynn,
I understood the code. But I have one more query regarding this, please help me out...
code in myjsp is:
<c:forEach items="${command.bill.billedServices}" var="billedServicesList" varStatus="loop">
<tr>
<td><c:out value="${billedServicesList.service}"/></td>
<td>
<spring:bind path="command.bill.billedServices[${loop.index}].amount">
<input name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>">
<c:if test="${status.error}">
<ul>
<c:forEach var="errorMessage" items="${status.errorMessages}">
<li><c:out value="${errorMessage}" /></li>
</c:forEach>
</ul>
</c:if>
</spring:bind>
</td>
</tr>
</c:forEach>

Now I want to change billedServices type in Bill.java class as Set. How to do data binding?
Thanks in advance.

infinity2heaven
Sep 11th, 2007, 10:46 AM
I think jstl <c:foreach> does iterate over Sets too. See this post (http://forum.springframework.org/showthread.php?t=10408)for reference