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/01/04 01:58:56 UTC

svn commit: r608700 - in /velocity/tools/trunk/examples/showcase: WEB-INF/src/resources.properties alternator.vm class.vm context.vm demo.vm

Author: nbubna
Date: Thu Jan  3 16:58:54 2008
New Revision: 608700

URL: http://svn.apache.org/viewvc?rev=608700&view=rev
Log:
various updates and improvements

Modified:
    velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties
    velocity/tools/trunk/examples/showcase/alternator.vm
    velocity/tools/trunk/examples/showcase/class.vm
    velocity/tools/trunk/examples/showcase/context.vm
    velocity/tools/trunk/examples/showcase/demo.vm

Modified: velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties?rev=608700&r1=608699&r2=608700&view=diff
==============================================================================
--- velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties (original)
+++ velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties Thu Jan  3 16:58:54 2008
@@ -86,11 +86,21 @@
 
 # alternator.vm resources
 alternator.intro = The <a href="#fullDemo">example</a> at the bottom is a good \
-    demonstration of the difference between an automatic {0} and a manual one.
+    demonstration of the difference between an automatic {0} and a manual one. \
+    <br><br>Please see the javadoc for {0} to understand how they work and the methods \
+    you can call on them. \
+    <br><br>Also note that the varargs methods here only work fully with Velocity 1.6 \
+    (which supports vararg method calls).  The old non-vararg versions are still \
+    available (as seen in the <a href="#fullDemo">demo below</a>).  But they are \
+    deprecated (and thus not listed below) to discourage those extending this \
+    tool or using it outside Velocity templates from depending on those methods.
 alternator.getAutoAlternateDefault = Returns <code>true</code> if Alternators created by this tool will auto-alternate by default.
 alternator.make = Returns a new, default Alternator that alternates over the specified values.
+alternator.make_booleanObjectVarArgs = Returns a new Alternater that alternates of the specified values using the specified auto-alternate setting.
 alternator.auto = Returns a new, automatically alternating Alternator that alternates over the specified values.
+alternator.auto_ObjectVarArgs.param1 = ['b','c','a']
 alternator.manual = Returns a new, manually alternating Alternator that alternates over the specified values.
+alternator.manual_ObjectVarArgs.param1 = ['red','green']
 alternator.custom = $alternator.make(['b','c','a'])
 
 # class.vm resources
@@ -103,12 +113,15 @@
     configure it to be <code>false</code>. \
     When <code>true</code>, safeMode will restrict ClassTool (or any instances it creates) to \
     only inspecting classes, methods, fields and constructors that were declared <code>public</code>.
+class.getAnnotations = Returns a list of the <code>Annotations</code> of the class being inspected.
 class.getConstructors = Returns a list of <code>ConstructorSub</code>s for each constructor declared in the inspected class.
 class.getFields = Returns a list of <code>FieldSub</code>s for each field declared in the inspected class.
 class.getFullName = Returns the fully qualified name of the class being inspected.
 class.getMethods = Returns a list of <code>MethodSub</code>s for each method declared in the inspected class.
 class.getName = Returns the simple name of the class being inspected.
 class.getPackage = Returns the package name of the class being inspected.
+class.getShowDeprecated = Returns the current showDeprecated setting.
+class.getSafeMode = Returns the current safeMode setting.
 class.getType = Returns the actual <code>Class</code> being inspected.
 class.getTypes = Returns a <code>Set</code> of all <code>Class</code>es that are part of the signatures (i.e. parameters or return types) of the inspected Class's methods, constructors and fields.
 class.inspectSuper = Returns a new ClassTool instance that inspects the immediate superclass of the class being inspected.
@@ -129,6 +142,15 @@
 class.isStrict = Returns <code>true</code> if the class being inspected is declared strict.
 class.supportsNewInstance = Returns <code>true</code> if a new instance of the class being inspected can be created via $class.type.newInstance().
 class.toString = Returns the result of $class.type.toString().
+
+# context.vm resources
+context.intro = This tool exists to provide access to the current context and various attributes of it.
+context.getThis = Returns the <code>ViewContext</code> currently being analyzed by this tool.
+context.contains = Returns <code>true</code> if there is a value available in the current request context for the specified key.
+context.get = Returns the value for the specified key in the current request context.
+context.getKeys = Returns a java.util.Set of the keys available in the current request context
+context.getToolbox = Returns a java.util.Map of the tools available in the current request context and their context keys.
+context.getValues = Returns a java.util.Set of the values available in the current request context.
 
 # field.vm resources
 field.intro = This tool allows easy access to public static fields in classes,  such as string constants.

Modified: velocity/tools/trunk/examples/showcase/alternator.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/alternator.vm?rev=608700&r1=608699&r2=608700&view=diff
==============================================================================
--- velocity/tools/trunk/examples/showcase/alternator.vm (original)
+++ velocity/tools/trunk/examples/showcase/alternator.vm Thu Jan  3 16:58:54 2008
@@ -34,46 +34,3 @@
 )
 
 #parse( 'demo.vm' )
-#*
-#demoTableStart()
-
-#set( $quote = '' )
-
-alternator.autoAlternateDefault = Returns <code>true</code> if Alternators created by this tool will auto-alternate by default.
-alternator.make = Returns a new, default Alternator that alternates over the specified values.
-alternator.auto = Returns a new, automatically alternating Alternator that alternates over the specified values.
-alternator.manual = Returns a new, manually alternating Alternator that alternates over the specified values.
-
-#demoCustom( "alternator.make(['b','c','a'])" )
-</table>
-
-<div align="center">
-  <a name="fullDemo"><h3>$demo.mainExampleHeader</h3></a>
-<form method="post" action="$link.self.anchor('fullDemo')">
-<textarea name="demo" rows="6" cols="65">##
-#if( $params.demo )##
-$params.demo##
-#else##
-${esc.h}set( ${esc.d}color = ${esc.d}alternator.auto('red', 'blue') )
-${esc.h}${esc.h} use manual alternation for this one
-${esc.h}set( ${esc.d}style = ${esc.d}alternator.manual(['hip','fly','groovy']) )
-${esc.h}foreach( ${esc.d}i in [1..5] )
- Number ${esc.d}i is ${esc.d}color and ${esc.d}style. I dig $style.next numbers.
-${esc.h}end##
-#end##
-</textarea>
-  <br>
-  <input type="submit" value="$demo.try">
-  #if( $params.layout )
-  <input type="hidden" name="layout" value="$params.layout">
-  #end
-</form>
-
-#if( $params.demo )
-$demo.mainResultsIntro:
-<pre>
-  $render.eval($params.demo)
-</pre>
-#end
-</div>
-*#
\ No newline at end of file

Modified: velocity/tools/trunk/examples/showcase/class.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/class.vm?rev=608700&r1=608699&r2=608700&view=diff
==============================================================================
--- velocity/tools/trunk/examples/showcase/class.vm (original)
+++ velocity/tools/trunk/examples/showcase/class.vm Thu Jan  3 16:58:54 2008
@@ -26,7 +26,8 @@
 #set( $toolclass = $class.class )
 #set( $toollink = $doclink )
 #set( $toolDemo = 
-"${esc.h}foreach( ${esc.d}method in ${esc.d}class.methods )
+"${esc.h}set( ${esc.d}classTool = ${esc.d}class.inspect(${esc.d}class) )
+${esc.h}foreach( ${esc.d}method in ${esc.d}classTool.methods )
 ${esc.d}method.javadocRef
 ${esc.h}end"
 )

Modified: velocity/tools/trunk/examples/showcase/context.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/context.vm?rev=608700&r1=608699&r2=608700&view=diff
==============================================================================
--- velocity/tools/trunk/examples/showcase/context.vm (original)
+++ velocity/tools/trunk/examples/showcase/context.vm Thu Jan  3 16:58:54 2008
@@ -16,56 +16,19 @@
 ## under the License.
 #title( 'ContextTool' )
 <p>
-#set( $demo = $text.demo )
-$demo.thisPage.insert("#doclink( 'ContextTool' false )").
+$text.demo.thisPage.insert("#doclink( 'ContextTool' false )").
+</p>
+<p>
+$text.get('context.intro')
 </p>
 
-#demoTableStart()
-
-#set( $desc = 'Returns the ViewContext being analyzed by this tool' )
-#demo( 'context' 'this' $desc )
-
-#set( $desc = 'Returns <code>true</code> if there is a value available in the current request context for the specified key' )
-#demo1( 'context' 'contains' 6 $desc )
-
-#set( $desc = 'Returns the value for the specified key in the current request context' )
-#demo1( 'context' 'get' 6 $desc )
-
-#set( $desc = 'Returns a java.util.Set of the keys available in the current request context' )
-#demo( 'context' 'keys' $desc )
-
-#set( $desc = 'Returns a java.util.Map of the tools available in the current request context and their context keys' )
-#demo( 'context' 'toolbox' $desc )
-
-#set( $desc = 'Returns a java.util.Set of the values available in the current request context' )
-#demo( 'context' 'values' $desc )
-
-#demoCustom( 'context' )
-</table>
-
-<div align="center">
-  <a name="fullDemo"><h3>$demo.mainExampleHeader</h3></a>
-<form method="post" action="$link.self.anchor('fullDemo')">
-<textarea name="demo" rows="6" cols="65">##
-#if( $params.demo )##
-$params.demo##
-#else##
-${esc.h}foreach( ${esc.d}key in ${esc.d}context.keys )
+#set( $toolname = 'context' )
+#set( $toolclass = $context.class )
+#set( $toollink = $doclink )
+#set( $toolDemo = 
+"${esc.h}foreach( ${esc.d}key in ${esc.d}context.keys )
   ${esc.d}key = ${esc.d}context.get(${esc.d}key)
-${esc.h}end##
-#end##
-</textarea>
-  <br>
-  <input type="submit" value="$demo.try">
-  #if( $params.layout )
-  <input type="hidden" name="layout" value="$params.layout">
-  #end
-</form>
+${esc.h}end"
+)
 
-#if( $params.demo )
-$demo.mainResultsIntro:
-<pre>
-  $render.eval($params.demo)
-</pre>
-#end
-</div>
+#parse( 'demo.vm' )

Modified: velocity/tools/trunk/examples/showcase/demo.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/demo.vm?rev=608700&r1=608699&r2=608700&view=diff
==============================================================================
--- velocity/tools/trunk/examples/showcase/demo.vm (original)
+++ velocity/tools/trunk/examples/showcase/demo.vm Thu Jan  3 16:58:54 2008
@@ -49,6 +49,7 @@
 </tr>
 ## generate a demo for each method
 #foreach( $method in $tool.methods )
+#if( $method.signature != 'configure(Map)' )
 <tr>
   ## create a fake call of the method to use as the name/signature
   #set( $call = "${esc.d}${toolname}.#if( !$method.takesParameters() && $method.propertyName )$method.propertyName#else$method.signature#end" )
@@ -129,6 +130,7 @@
   #end
   <td valign="top">$desc</td>
 </tr>
+#end
 #end
 <tr>
   ## create a space for an extended, custom, one line demo