The Jakarta Project < Velocity Tools - Library >

Velocity Tools

Generic Tools

Tool Documentation

Other Subprojects

ToolLoader Reference Documentation
       

A view tool that allows template designers to load view tools from within the template. Any object with a public constructor without parameters can be loaded into the context. This tool is considered by the developers to be merely a development tool and inappropriate for use in a production setting.

Class
 org.apache.velocity.tools.generic.ToolLoader
Name
 $toolLoader (this is the recommended name of the tool in the Velocity context)
Toolbox Configuration Example
 
<tool>
  <key>toolLoader</key>
  <scope>application</scope>
  <class>org.apache.velocity.tools.generic.ToolLoader</class>
</tool>
Author(s)
 Gabriel Sidler
Method Overview
load() Loads an instance of a tool and returns it.
load()
       

Loads an instance of a tool and returns it.

void load(String class)

Parameters
class
The name of the class to instantiate.

example:


#set( $math = $toolLoader.load("org.apache.velocity.tools.generic.MathTool") )
$math.random(1,1000)

Loads MathTool with name $math into the context. Then, its random() function is used to generate a random number between 1 and 1000.



Copyright © 1999-2003, Apache Software Foundation