jvanzyl 00/10/20 23:24:14
Modified: docs vtl-reference-guide.html
Log:
- added #foreach docs.
Revision Changes Path
1.6 +58 -0 jakarta-velocity/docs/vtl-reference-guide.html
Index: vtl-reference-guide.html
===================================================================
RCS file: /home/cvs/jakarta-velocity/docs/vtl-reference-guide.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- vtl-reference-guide.html 2000/10/21 06:12:24 1.5
+++ vtl-reference-guide.html 2000/10/21 06:24:14 1.6
@@ -273,6 +273,64 @@
<P align="justify">
<B>#foreach</B>
<BR>
+ The #foreach directive provide a simple way of looping
+ through a list of objects:
+</P>
+
+<P align="justify">
+ <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="0"><TR><TD
bgcolor="#023264" colspan="3" height="1"><IMG border="0" height="1" hspace="0"
src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#023264"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#ffffff"><TABLE><TR><TD align="left"><PRE>
+ <table>
+ #foreach ($customer in $customerList)
+ <tr>
+ <td>
+ $customer.Name
+ </td>
+ </tr>
+ #end
+ </PRE></TD></TR></TABLE></TD><TD bgcolor="#023264" width="1"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD
bgcolor="#023264" colspan="3" height="1"><IMG border="0" height="1" hspace="0"
src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
+</P>
+
+<P align="justify">
+ Velocity provides an easy way to get the loop
+ counter so that you can do something like the
+ following:
+</P>
+
+<P align="justify">
+ <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="0"><TR><TD
bgcolor="#023264" colspan="3" height="1"><IMG border="0" height="1" hspace="0"
src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#023264"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#ffffff"><TABLE><TR><TD align="left"><PRE>
+ <table>
+ #foreach ($customer in $customerList)
+ <tr>
+ <td>
+ $velocityCounter
+ </td>
+ <td>
+ $customer.Name
+ </td>
+ </tr>
+ #end
+ </PRE></TD></TR></TABLE></TD><TD bgcolor="#023264" width="1"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD
bgcolor="#023264" colspan="3" height="1"><IMG border="0" height="1" hspace="0"
src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
+</P>
+
+<P align="justify">
+ The default name for the loop counter variable
+ reference is $velocityCounter, but you can specify
+ this in the velocity.properties file. You can also
+ specify whether the counter should start at 0 or 1.
+ Here's what the properties look like in the
+ velocity.properties file:
+</P>
+
+<P align="justify">
+ <DIV align="left"><TABLE border="0" cellpadding="0" cellspacing="0"><TR><TD
bgcolor="#023264" colspan="3" height="1"><IMG border="0" height="1" hspace="0"
src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#023264"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#ffffff"><TABLE><TR><TD align="left"><PRE>
+ # Default name of the loop counter
+ # variable refernce.
+ counter.name = velocityCount
+
+ # Default starting value of the loop
+ # counter variable reference.
+ counter.initial.value = 1
+ </PRE></TD></TR></TABLE></TD><TD bgcolor="#023264" width="1"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD
bgcolor="#023264" colspan="3" height="1"><IMG border="0" height="1" hspace="0"
src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
</P>
<P align="justify">