jon 01/06/11 14:45:37
Modified: docs user-guide.html
xdocs user-guide.xml
Log:
added examples of how to get key/value pairs out of a hashtable based on
feedback from the mailing list
Revision Changes Path
1.39 +30 -0 jakarta-velocity/docs/user-guide.html
Index: user-guide.html
===================================================================
RCS file: /home/cvs/jakarta-velocity/docs/user-guide.html,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- user-guide.html 2001/06/11 19:43:58 1.38
+++ user-guide.html 2001/06/11 21:45:23 1.39
@@ -1870,6 +1870,36 @@
in Java, its name could be retrieved by referencing the
<em>$product.Name</em> method (ie: <em>$Product.getName()</em>).
</p>
+ <p>
+ Lets say that $allProducts is a Hashtable. If you wanted to retrieve
+ the key values for the Hashtable as well as the objects within the
+ Hashtable, you can use code like this:
+ </p>
+ <div align="left">
+ <table cellspacing="4" cellpadding="0" border="0">
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#ffffff"><pre>
+<ul>
+#foreach( $key in $allProducts.keySet() )
+ <li>Key: $key -> Value: $allProducts.get($key)</li>
+#end
+</ul>
+</pre></td>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ </table>
+ </div>
</blockquote>
</p>
</td></tr>
1.42 +13 -0 jakarta-velocity/xdocs/user-guide.xml
Index: user-guide.xml
===================================================================
RCS file: /home/cvs/jakarta-velocity/xdocs/user-guide.xml,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- user-guide.xml 2001/06/11 19:44:02 1.41
+++ user-guide.xml 2001/06/11 21:45:32 1.42
@@ -1073,6 +1073,19 @@
<em>$product.Name</em> method (ie: <em>$Product.getName()</em>).
</p>
+ <p>
+ Lets say that $allProducts is a Hashtable. If you wanted to retrieve
+ the key values for the Hashtable as well as the objects within the
+ Hashtable, you can use code like this:
+ </p>
+
+<source><![CDATA[
+<ul>
+#foreach( $key in $allProducts.keySet() )
+ <li>Key: $key -> Value: $allProducts.get($key)</li>
+#end
+</ul>
+]]></source>
</section>