title: JSF 'total' variable for datatable
body: <p>I have read the previous post: <a href="https://stackoverflow.com/q/1559689">JSF &#39;total&#39; variable something like c:set in JSTL</a>.  Although the answer suggests that the total should come from the backing bean, I have genuine need to do it in the facelet.  For my case, I want to display a bank book type datatable, with each row consisting of a date, a description, an amount and a <strong>running total</strong>.  The data  come from a JPA get of type List&lt;Entity&gt;.  If I did the total in the backing bean I need to iterate the List, create a data model solely for the purpose of a running-total property.  This is inefficient indeed.</p>
  
  <p>I tried:</p>
  
  <pre><code>&lt;c:set var="sum" value="0.0" scope="view" /&gt;
      &lt;table&gt;
  &lt;ui:repeat value="#{xxxBean.items}" var="item"&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;h:outputText value="#{item.date1}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;h:outputText value="#{item.desc}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;h:outputText value="#{item.amount}" /&gt;&lt;/td&gt;
      &lt;c:set var="sum" value="${sum+item.amount}"/&gt;
          &lt;td&gt;&lt;h:outputText value="${sum}" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/ui:repeat&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>but it does not work, ${sum} resets to zero for each row.  Is there another way, except making a custom component?</p>