You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2008/08/19 21:07:21 UTC

svn commit: r687133 - /velocity/engine/trunk/xdocs/docs/developer-guide.xml

Author: nbubna
Date: Tue Aug 19 12:07:21 2008
New Revision: 687133

URL: http://svn.apache.org/viewvc?rev=687133&view=rev
Log:
VELOCITY-102 document static utility class support

Modified:
    velocity/engine/trunk/xdocs/docs/developer-guide.xml

Modified: velocity/engine/trunk/xdocs/docs/developer-guide.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/xdocs/docs/developer-guide.xml?rev=687133&r1=687132&r2=687133&view=diff
==============================================================================
--- velocity/engine/trunk/xdocs/docs/developer-guide.xml (original)
+++ velocity/engine/trunk/xdocs/docs/developer-guide.xml Tue Aug 19 12:07:21 2008
@@ -60,6 +60,7 @@
 <ul>
 <li><a href="#thebasics">The Basics</a></li>
 <li><a href="#supportforiterativeobjectsforforeach">Support for Iterative Objects for #foreach()</a></li>
+<li><a href="#supportforstaticclasses">Support for "Static Classes"</a></li>
 <li><a href="#contextchaining">Context Chaining</a></li>
 <li><a href="#objectscreatedinthetemplate">Objects Created by the Template</a></li>
 <li><a href="#othercontextissues">Other Context Issues</a></li>
@@ -654,6 +655,22 @@
 careful when you place an Iterator into the context.
 </p>
 
+<a name="supportforstaticclasses"><strong>Support for "Static Classes"</strong></a>
+
+<p>Not all classes are instantiable.  Classes like <code>java.lang.Math</code>
+do not provide any public constructor, and yet may contain useful static methods.
+In order to access these static methods from a template, you can simply add the
+class itself to the context:
+</p>
+
+<source><![CDATA[
+context.put("Math", Math.class);
+]]></source>
+
+<p>This will allow you to call any public static method in <code>java.lang.Math</code>
+on the <code>$Math</code> reference in the template.
+</p>
+
 <a name="contextchaining"><strong>Context Chaining</strong></a>
 
 <p>