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 2007/01/19 23:59:28 UTC

svn commit: r497996 - in /velocity/tools/trunk/examples/showcase: WEB-INF/src/otherStuff.properties WEB-INF/src/resources.properties WEB-INF/src/resources_de.properties WEB-INF/src/resources_fr.properties WEB-INF/toolbox.xml text.vm toolmenu.vm

Author: nbubna
Date: Fri Jan 19 14:59:27 2007
New Revision: 497996

URL: http://svn.apache.org/viewvc?view=rev&rev=497996
Log:
add demo page for ResourcesTool

Added:
    velocity/tools/trunk/examples/showcase/WEB-INF/src/otherStuff.properties   (with props)
    velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties   (with props)
    velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_de.properties   (with props)
    velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_fr.properties   (with props)
    velocity/tools/trunk/examples/showcase/text.vm   (with props)
Modified:
    velocity/tools/trunk/examples/showcase/WEB-INF/toolbox.xml
    velocity/tools/trunk/examples/showcase/toolmenu.vm

Added: velocity/tools/trunk/examples/showcase/WEB-INF/src/otherStuff.properties
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/WEB-INF/src/otherStuff.properties?view=auto&rev=497996
==============================================================================
--- velocity/tools/trunk/examples/showcase/WEB-INF/src/otherStuff.properties (added)
+++ velocity/tools/trunk/examples/showcase/WEB-INF/src/otherStuff.properties Fri Jan 19 14:59:27 2007
@@ -0,0 +1,2 @@
+foo= woogie
+baz= The args are {0} and {1}.

Propchange: velocity/tools/trunk/examples/showcase/WEB-INF/src/otherStuff.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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?view=auto&rev=497996
==============================================================================
--- velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties (added)
+++ velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties Fri Jan 19 14:59:27 2007
@@ -0,0 +1,3 @@
+foo = bar
+hello.whoever = Hello {0}!
+world = World

Propchange: velocity/tools/trunk/examples/showcase/WEB-INF/src/resources.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_de.properties
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_de.properties?view=auto&rev=497996
==============================================================================
--- velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_de.properties (added)
+++ velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_de.properties Fri Jan 19 14:59:27 2007
@@ -0,0 +1,3 @@
+foo = Stab
+hello.whoever = Hallo {0}!
+world = Welt

Propchange: velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_de.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_fr.properties
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_fr.properties?view=auto&rev=497996
==============================================================================
--- velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_fr.properties (added)
+++ velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_fr.properties Fri Jan 19 14:59:27 2007
@@ -0,0 +1,3 @@
+foo = barre
+hello.whoever = Bonjour {0}!
+world = Monde

Propchange: velocity/tools/trunk/examples/showcase/WEB-INF/src/resources_fr.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: velocity/tools/trunk/examples/showcase/WEB-INF/toolbox.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/WEB-INF/toolbox.xml?view=diff&rev=497996&r1=497995&r2=497996
==============================================================================
--- velocity/tools/trunk/examples/showcase/WEB-INF/toolbox.xml (original)
+++ velocity/tools/trunk/examples/showcase/WEB-INF/toolbox.xml Fri Jan 19 14:59:27 2007
@@ -73,6 +73,12 @@
     <class>org.apache.velocity.tools.view.tools.ViewRenderTool</class>
     <parameter name="catch.exceptions" value="true"/>
   </tool>
+  <tool>
+    <key>text</key>
+    <scope>request</scope>
+    <class>org.apache.velocity.tools.view.tools.ViewResourceTool</class>
+    <parameter name="bundles" value="resources,otherStuff"/>
+  </tool>
 
   <tool>
     <key>alternator</key>

Added: velocity/tools/trunk/examples/showcase/text.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/text.vm?view=auto&rev=497996
==============================================================================
--- velocity/tools/trunk/examples/showcase/text.vm (added)
+++ velocity/tools/trunk/examples/showcase/text.vm Fri Jan 19 14:59:27 2007
@@ -0,0 +1,84 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+#title( 'ResourceTool' )
+<p>
+This page demonstrates functions of the #doclink( 'ViewResourceTool' false ).  This tool
+is similar to the <a href="$link.relative('link.vm')">LinkTool</a> in that most methods
+return a new object that has mostly the same methods as the original, allowing you
+to build up parameters elegantly and simply, rather than try to remember how to use
+methods with many parameters that must be in a specific order.  So, you can access a
+resource with the key 'hello.whoever' in the 'otherStuff' bundle with one message
+argument like this:
+<pre>
+  ${esc.d}text.hello.whoever.bundle('otherStuff').insert('World')
+</pre>
+instead of like this:
+<pre>
+  ${esc.d}text.get('hello.whoever','otherStuff', $null, 'World')
+</pre>
+While the former is somewhat longer, it is much more understandable and flexible.
+</p>
+
+#demoTableStart()
+
+#set( $desc = 'Returns the resource with the specified name, if it exists.' )
+#demo1( 'text' 'get' 9 $desc )
+
+#set( $desc = 'Returns a new $text that will search only the specified bundle (if it exists) for the resource "foo".' )
+#demo1( 'text.foo' 'bundle' 9 $desc )
+
+#set( $quote = '' )
+#set( $desc = 'Returns a new $text that will try to find the resource "foo" for the specified Locale.' )
+#demo1( 'text.foo' 'locale' 9 $desc )
+
+#set( $quote = '"' )
+#set( $desc = 'Returns the resource "hello.whoever" with the specified value inserted.' )
+#demo1( 'text.hello.whoever' 'insert' 9 $desc )
+
+#set( $desc = 'Returns the resource "baz" with the specified values inserted.' )
+#demo2( 'text.baz' 'insert' 9 $desc )
+
+#demoCustom( 'text' )
+</table>
+
+<div align="center">
+  <a name="fullDemo"><h3>Example Display</h3></a>
+<form method="post" action="$link.self.anchor('fullDemo')">
+<textarea name="demo" rows="6" cols="65">##
+#if( $params.demo )##
+$params.demo##
+#else##
+${esc.d}text.foo
+${esc.d}text.hello.whoever
+${esc.d}text.hello.whoever.insert(${esc.d}text.world)
+${esc.d}text.bundle('otherStuff').foo##
+#end##
+</textarea>
+  <br>
+  <input type="submit" value="Try it!">
+  #if( $params.layout )
+  <input type="hidden" name="layout" value="$params.layout">
+  #end
+</form>
+
+#if( $params.demo )
+Your code returned the following results:
+<pre>
+  $render.eval($params.demo)
+</pre>
+#end
+</div>

Propchange: velocity/tools/trunk/examples/showcase/text.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: velocity/tools/trunk/examples/showcase/toolmenu.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/toolmenu.vm?view=diff&rev=497996&r1=497995&r2=497996
==============================================================================
--- velocity/tools/trunk/examples/showcase/toolmenu.vm (original)
+++ velocity/tools/trunk/examples/showcase/toolmenu.vm Fri Jan 19 14:59:27 2007
@@ -36,6 +36,7 @@
 #toolMenuItem( $llink 'pager'      'PagerTool' )
 #toolMenuItem( $llink 'params'     'ParameterParser' )
 #toolMenuItem( $llink 'render'     'RenderTool' )
+#toolMenuItem( $llink 'text'       'ResourceTool' )
 #toolMenuItem( $llink 'search'     'SearchTool' )
 #toolMenuItem( $llink 'sorter'     'SortTool' )
 </ul>