Modified: velocity/site/production/engine/devel/webapps.html URL: http://svn.apache.org/viewvc/velocity/site/production/engine/devel/webapps.html?rev=1834366&r1=1834365&r2=1834366&view=diff ============================================================================== --- velocity/site/production/engine/devel/webapps.html (original) +++ velocity/site/production/engine/devel/webapps.html Mon Jun 25 18:46:53 2018 @@ -268,14 +268,14 @@ webapp.resource.loader.path=/WEB-INF/myt <h3 id="changing-object-state-dont">Changing Object State - Don't!<a class="headerlink" href="#changing-object-state-dont" title="Permanent link">¶</a></h3> <p>Velocity provides the ability to call any method of an object acting as a reference. This can be useful when displaying information into the page but is dangerous when object or application state is modified.</p> <p>For example, the following code safely calls the size() method of a list and displays the result.</p> -<div class="codehilite"><pre><span class="x">There are </span><span class="p">$</span><span class="nv">users</span><span class="p">.</span><span class="nv">size</span><span class="p">()</span><span class="x"> currently logged in.</span> +<div class="codehilite"><pre>There are $users.size() currently logged in. </pre></div> <p>An example of an unsafe operation concerns a financial web page with an object in the context that calculates data year by year. The method calculateNextYear() calculates data for the next year and advances an internal counter:</p> -<div class="codehilite"><pre><span class="x">2005 data: </span><span class="p">$</span><span class="nv">table</span><span class="p">.</span><span class="nv">data</span><span class="x"></span> -<span class="p">$</span><span class="nv">table</span><span class="p">.</span><span class="nv">calculateNextYear</span><span class="p">()</span><span class="x"></span> -<span class="x">2006 data: </span><span class="p">$</span><span class="nv">table</span><span class="p">.</span><span class="nv">data</span><span class="x"></span> +<div class="codehilite"><pre>2005 data: $table.data +$table.calculateNextYear() +2006 data: $table.data </pre></div>
Modified: velocity/site/production/tools/2.0/creating-tools.html URL: http://svn.apache.org/viewvc/velocity/site/production/tools/2.0/creating-tools.html?rev=1834366&r1=1834365&r2=1834366&view=diff ============================================================================== --- velocity/site/production/tools/2.0/creating-tools.html (original) +++ velocity/site/production/tools/2.0/creating-tools.html Mon Jun 25 18:46:53 2018 @@ -324,7 +324,7 @@ public class PagerTool </ul> <h3 id="be-robust">Be Robust<a class="headerlink" href="#be-robust" title="Permanent link">¶</a></h3> <p>Always return null on errors! No Exceptions! Ok, maybe there are some exceptions if you are sure that's what you want your tool to do. Just be aware that this will likely surprise the user because uncaught exceptions halt template processing at the point the exception is thrown. If the output of the template is not buffered, this will result in an awkward, partial rendering. So, if you are going to let an exception through, make sure it is worth halting everything for. Often it is sufficient to return null, thus allowing the failed reference to appear in the output like this:</p> -<div class="codehilite"><pre><span class="p">$</span><span class="nv">mytool</span><span class="p">.</span><span class="nv">somemethod</span><span class="p">(</span><span class="s1">'bad input'</span><span class="p">)</span><span class="x"></span> +<div class="codehilite"><pre>$mytool.somemethod('bad input') </pre></div> Modified: velocity/site/production/tools/2.0/standalone.html URL: http://svn.apache.org/viewvc/velocity/site/production/tools/2.0/standalone.html?rev=1834366&r1=1834365&r2=1834366&view=diff ============================================================================== --- velocity/site/production/tools/2.0/standalone.html (original) +++ velocity/site/production/tools/2.0/standalone.html Mon Jun 25 18:46:53 2018 @@ -218,10 +218,10 @@ h2:hover > .headerlink, h3:hover > .head <p>There's nothing particularly special about the tools in VelocityTools 2. No special interfaces, most don't ''need'' any configuration or API access, and those that do are now relatively easy to handle (compared to VelocityTools 1.x). So, if you need a tool, just create an instance, do any configuration you want or need and go. Nothing else to it.</p> <h2 id="toolmanager">ToolManager<a class="headerlink" href="#toolmanager" title="Permanent link">¶</a></h2> <p>However, if you want to externalize your configuration or have your tools created and configured for you on demand and you are not working in a servlet environment, then we have created a simple ToolManager that you can use. It's relatively simple. Just create a ToolManager (can be created with or without default tools available), configure it (if you want to), ask it to create a context for you, and use the context as you would any other. Of course, there's more to it, but this should get you started:</p> -<div class="codehilite"><pre><span class="x">ToolManager manager = new ToolManager();</span> -<span class="x">manager.configure("/path/to/my/configuration.xml");</span> -<span class="x">Context context = manager.createContext();</span> -<span class="x">myVelocityEngine.evaluate(context, myOutputWriter, "This is a </span><span class="p">$</span><span class="nv">text</span><span class="p">.</span><span class="nv">test</span><span class="x">", "Test template");</span> +<div class="codehilite"><pre>ToolManager manager = new ToolManager(); +manager.configure("/path/to/my/configuration.xml"); +Context context = manager.createContext(); +myVelocityEngine.evaluate(context, myOutputWriter, "This is a $text.test", "Test template"); </pre></div> Modified: velocity/site/production/tools/2.0/struts-user-guide.html URL: http://svn.apache.org/viewvc/velocity/site/production/tools/2.0/struts-user-guide.html?rev=1834366&r1=1834365&r2=1834366&view=diff ============================================================================== --- velocity/site/production/tools/2.0/struts-user-guide.html (original) +++ velocity/site/production/tools/2.0/struts-user-guide.html Mon Jun 25 18:46:53 2018 @@ -382,7 +382,7 @@ session.setAttribute("foo", &q <p>then the request attribute will take priority, and using </p> -<div class="codehilite"><pre><span class="p">$</span><span class="nv">foo</span><span class="x"></span> +<div class="codehilite"><pre>$foo </pre></div> @@ -511,10 +511,10 @@ foo.bar=whatever <p>Then, the following script...</p> -<div class="codehilite"><pre><span class="p">$</span><span class="nv">text</span><span class="p">.</span><span class="nv">title</span><span class="x"></span> -<span class="p">$</span><span class="nv">text</span><span class="p">.</span><span class="nv">get</span><span class="p">(</span><span class="s1">'test'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bear'</span><span class="p">,</span> <span class="s1">'dog'</span><span class="p">,</span> <span class="s1">'cat'</span><span class="p">])</span><span class="x"></span> -<span class="p">$</span><span class="nv">text</span><span class="p">.</span><span class="nv">exists</span><span class="p">(</span><span class="s1">'tutle'</span><span class="p">)</span><span class="x"></span> -<span class="p">$</span><span class="nv">text</span><span class="p">.</span><span class="nv">foo</span><span class="p">.</span><span class="nv">bar</span><span class="x"></span> +<div class="codehilite"><pre>$text.title +$text.get('test', ['bear', 'dog', 'cat']) +$text.exists('tutle') +$text.foo.bar </pre></div> Modified: velocity/site/production/tools/2.0/view-layoutservlet.html URL: http://svn.apache.org/viewvc/velocity/site/production/tools/2.0/view-layoutservlet.html?rev=1834366&r1=1834365&r2=1834366&view=diff ============================================================================== --- velocity/site/production/tools/2.0/view-layoutservlet.html (original) +++ velocity/site/production/tools/2.0/view-layoutservlet.html Mon Jun 25 18:46:53 2018 @@ -238,7 +238,7 @@ tools.view.servlet.layout.default.templa <h2 id="layouts">Layouts<a class="headerlink" href="#layouts" title="Permanent link">¶</a></h2> <p>Now, in your layout templates, the only thing you really need is the screen content reference. So an acceptable layout template could be:</p> -<div class="codehilite"><pre><span class="p">$</span><span class="nv">screen_content</span><span class="x"></span> +<div class="codehilite"><pre>$screen_content </pre></div> @@ -261,7 +261,7 @@ tools.view.servlet.layout.default.templa <li> <p><strong>Specify the layout in the request parameters</strong></p> <p>Just add the query string "layout=MyOtherLayout.vm" to any request params and the VLS will find it and render your screen within that layout instead of the default layout. It don't matter how you get the layout param into the query data, only that it's there. If you're using the struts tools, the most common will likely be:</p> -<div class="codehilite"><pre><span class="x"><a href="</span><span class="p">$</span><span class="nv">link</span><span class="p">.</span><span class="nv">setRelative</span><span class="p">(</span><span class="s1">'MyScreen.vm'</span><span class="p">).</span><span class="nv">addQueryData</span><span class="p">(</span><span class="s1">'layout'</span><span class="p">,</span><span class="s1">'MyOtherLayout.vm'</span><span class="p">)</span><span class="x">"></span> +<div class="codehilite"><pre><a href="$link.setRelative('MyScreen.vm').addQueryData('layout','MyOtherLayout.vm')"> </pre></div> @@ -270,9 +270,9 @@ tools.view.servlet.layout.default.templa </li> </ol> <p>In the requested screen, put a line like this:</p> -<div class="codehilite"><pre><span class="x"> </span><span class="cp">#</span><span class="nf">set</span><span class="p">(</span> <span class="p">$</span><span class="nv">layout</span> <span class="o">=</span> <span class="s2">"MyOtherLayout.vm"</span> <span class="p">)</span><span class="x"></span> +<div class="codehilite"><pre> #set( $layout = "MyOtherLayout.vm" ) -<span class="x">This will direct the VLS to use "MyOtherLayout.vm" instead of "Default.vm". *Setting the layout in this fashion will override any layout set by the request parameters.*</span> +This will direct the VLS to use "MyOtherLayout.vm" instead of "Default.vm". *Setting the layout in this fashion will override any layout set by the request parameters.* </pre></div> @@ -340,13 +340,13 @@ $screen_content </tbody> </table> <p>In the event that a MethodInvocationException is behind the calling of error(), the root cause is extracted from it and dealt with as described above. But, since template reference behavior is partly at fault here, the VLS will also add the MethodInvocationException itself to the context as $invocation_exception. This allows you to discover the reference and method call that triggered the root cause. To get those, do something like this in your error template:</p> -<div class="codehilite"><pre><span class="cp">#</span><span class="nf">if</span><span class="p">(</span> <span class="p">$</span><span class="nv">invocation_exception</span> <span class="p">)</span><span class="x"></span> -<span class="x"> oh joy! it's a MethodInvocationException!</span> +<div class="codehilite"><pre>#if( $invocation_exception ) + oh joy! it's a MethodInvocationException! -<span class="x"> Message: </span><span class="p">$</span><span class="nv">invocation_exception</span><span class="p">.</span><span class="nv">message</span><span class="x"></span> -<span class="x"> Reference name: </span><span class="p">$</span><span class="nv">invocation_exception</span><span class="p">.</span><span class="nv">referenceName</span><span class="x"></span> -<span class="x"> Method name: </span><span class="p">$</span><span class="nv">invocation_exception</span><span class="p">.</span><span class="nv">methodName</span><span class="x"></span> -<span class="cp">#</span><span class="nf">end</span><span class="x"></span> + Message: $invocation_exception.message + Reference name: $invocation_exception.referenceName + Method name: $invocation_exception.methodName +#end </pre></div></div></div> <hr/> <div id="copyright"> Modified: velocity/site/production/tools/devel/dependencies.html URL: http://svn.apache.org/viewvc/velocity/site/production/tools/devel/dependencies.html?rev=1834366&r1=1834365&r2=1834366&view=diff ============================================================================== --- velocity/site/production/tools/devel/dependencies.html (original) +++ velocity/site/production/tools/devel/dependencies.html Mon Jun 25 18:46:53 2018 @@ -226,20 +226,36 @@ h2:hover > .headerlink, h3:hover > .head </thead> <tbody> <tr> +<td>velocity</td> +<td>2.0+</td> +<td>Yes</td> +<td>Yes</td> +<td>Yes</td> +<td>Required for core infrastructure and several tools</td> +</tr> +<tr> <td>commons-beanutils</td> -<td>1.7.0</td> +<td>1.9.3</td> <td>Yes</td> <td>Yes</td> <td>Yes</td> -<td>Required for core infrastructure, <a href="apidocs/org/apache/velocity/tools/generic/MathTool.html">MathTool</a> and <a href="apidocs/org/apache/velocity/tools/generic/DisplayTool.html">DisplayTool</a></td> +<td>Required for core infrastructure and several tools</td> </tr> <tr> -<td>commons-digester</td> +<td>commons-digester3</td> <td>3.2</td> <td>Yes</td> <td>Yes</td> <td>Yes</td> -<td>Required for <a href="config-xml.html">xml configuration</a> and <a href="apidocs/org/apache/velocity/tools/view/UiDependencyTool.html">UIDependencyTool</a></td> +<td>Required for <a href="config-xml.html">xml configuration</a> (and <a href="apidocs/org/apache/velocity/tools/view/UiDependencyTool.html">UIDependencyTool</a> view tool)</td> +</tr> +<tr> +<td>com.googlecode.json-simple</td> +<td>1.1.1</td> +<td>Yes</td> +<td>No</td> +<td>No</td> +<td>Required only at compilation time for <a href="apidocs/org/apache/velocity/tools/generic/JsonTool.html">JsonTool</a></td> </tr> <tr> <td>junit</td> @@ -249,14 +265,6 @@ h2:hover > .headerlink, h3:hover > .head <td>No</td> <td>Only required for tests.</td> </tr> -<tr> -<td>velocity</td> -<td>2.0+</td> -<td>Yes</td> -<td>Yes</td> -<td>Yes</td> -<td>Required for core infrastructure, <a href="apidocs/org/apache/velocity/tools/generic/ClassTool.html">ClassTool</a>, <a href="apidocs/org/apache/velocity/tools/generic/LinkTool.html">LinkTool</a>, <a href="apidocs/org/apache/velocity/tools/generic/LoopTool.html">LoopTool</a>, <a href="apidocs/org/apache/velocity/tools/generic/RenderTool.html">RenderTool</a> and <a href="apidocs/org/apache/velocity/tools/generic/XmlTool.html">XmlTool</a></td> -</tr> </tbody> </table> <h3 id="velocityview">VelocityView<a class="headerlink" href="#velocityview" title="Permanent link">¶</a></h3> @@ -273,20 +281,12 @@ h2:hover > .headerlink, h3:hover > .head </thead> <tbody> <tr> -<td>junit</td> -<td>4.12</td> -<td>No</td> +<td>velocity-tools-generic</td> +<td>3.0</td> <td>Yes</td> -<td>No</td> -<td>Only required for tests.</td> -</tr> -<tr> -<td>easymock</td> -<td>3.4</td> -<td>No</td> <td>Yes</td> -<td>No</td> -<td>Only required for tests.</td> +<td>Yes</td> +<td></td> </tr> <tr> <td>servletapi</td> @@ -294,15 +294,23 @@ h2:hover > .headerlink, h3:hover > .head <td>Yes</td> <td>Yes</td> <td>No</td> -<td>Required for all <a href="apidocs/org/apache/velocity/tools/view/package-summary.html">VelocityView</a> tools except for <a href="apidocs/org/apache/velocity/tools/generic/RenderTool.html">RenderTool</a>. Provided by the J2EE container at runtime.</td> +<td>Required for most view tools (provided by the J2EE container)</td> </tr> <tr> -<td>velocity-tools-generic</td> -<td>3.0</td> -<td>Yes</td> +<td>junit</td> +<td>4.12</td> +<td>No</td> <td>Yes</td> +<td>No</td> +<td>Only required for tests</td> +</tr> +<tr> +<td>easymock</td> +<td>3.6</td> +<td>No</td> <td>Yes</td> -<td></td> +<td>No</td> +<td>Only required for tests</td> </tr> </tbody> </table>