just in ram

A list of stuff I should remember but never do

Monorail + NVelocity + How to find out if your in the first item of a foreach loop?

without comments

A colleague needed to add a button to the first row of a table but how do you do this in a foreach loop?

NVelocity has a property called $velocityCount which you can check within the foreach loop:

<table>
#foreach($detail in $details)
  <tr>
    <td>
      $detail.ShortText)
      #if($velocityCount == 1) First Row! #end
    </td>
  </tr>
#end
</table>

Written by Justin Ramel

May 17th, 2007 at 10:41 am

Posted in MonoRail

Leave a Reply