Hi - 

In a Velocity template, I am attempting to generate a total for all the detail lines 
displayed on the page.  However, the total is always displaying zero. 

Here is what my code currently looks like:

 #set($totalBlockScale = 0)
 #foreach ($greenLoadDetail in $load.GreenLoadDetails)
    #foreach ($packDetail in $greenLoadDetail.PackDetails)
    <tr>
       ...cut other columns...
     <td>$packDetail.blockScale</td>
     #set($totalBlockScale = $int.valueOf($totalBlockScale) + 
$int.valueOf($packDetail.blockScale))
   </tr>
  #end
 #end

 <tr>
   <td colspan="8">Block Scale Total:</td>
   <td>$totalBlockScale</td>
 </tr>

This code correctly displays all the detail lines, but the total is always displayed 
as zero.  $packDetail.blockScale does have valid numeric values.  If I change the 
#set($totalBlockScale = 0) line to something like #set($totalBlockScale = 5000), then 
the total is displayed as 5000.  So for some reason, each detail line is not 
incrementing the $totalBlockScale variable. 

Can someone help me with what I am doing wrong?

Thanks,
Dave

Reply via email to