Try this:

<jx:set var="total" value="${0}"/>
<jx:set var="cost" value="${0}"/>
<jx:forEach var="activity" items="${bean.planActivityList}">
 <jx:forEach var="item" items="${activity.planCostList}">
   <jx:set var="total" value="${item.pco_total + total}"/>
   <jx:set var="cost" value="${item.pco_cost + cost}"/>
 </jx:forEach>
</jx:forEach>
<td><jx:formatNumber value="${total}"/></td>
<td><jx:formatNumber value="${cost}"/></td>
<td><jx:formatNumber value="${total - cost}"/></td>


or if you insist on using XPath:


<jx:set var="total" value="#{0}"/>
<jx:set var="cost" value="#{0}"/>
<jx:forEach var="activity" items="#{bean/planActivityList}">
 <jx:forEach var="item" items="#{$activity/planCostList}">
   <jx:set var="total" value="#{$item/pco_total + $total}"/>
   <jx:set var="cost" value="#{$item/pco_cost + $cost}"/>
 </jx:forEach>
</jx:forEach>
<td><jx:formatNumber value="#{$total}"/></td>
<td><jx:formatNumber value="#{$cost}"/></td>
<td><jx:formatNumber value="#{$total - $cost}"/></td>


But if your data consists of Java beans (as in this case) I recommend you stick with Jexl as the expression language.


HTH,

Chris

Antonio Gallardo wrote:

Hi:

I am trying to get the sum of some values inside 2 <jxForEach>. Here is
the code:

<jx:set var="total" value="${0}"/>
<jx:set var="costo" value="${0}"/>
<jx:forEach var="activity" items="${bean.planActivityList}">
 <jx:forEach var="item" items="${activity.planCostList}">
   <jx:set var="total" value="#{item.pco_total + $total}"/>
   <jx:set var="cost" value="#{item.pco_cost + $cost}"/>
 </jx:forEach>
</jx:forEach>
<td><jx:formatNumber value="#{$total}"/></td>
<td><jx:formatNumber value="#{$cost}"/></td>
<td><jx:formatNumber value="#{$total - $cost}"/></td>

The problem is that this always return 0 values.

What I am doing wrong?

Best Regards,

Antonio Gallardo

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to