Do you mean :

"How to put a new instance of a class in the velocity context from
inside the vtl?"

Usually, you put classes in the context using java
(context.put("name",object)), or using toolbox.xml if you rely on the
VelocityTools subproject.

Now, if you really want to load a new instance of a class in the context
from inside the VTL, you have the following hack:

#set($newobject = $foo.class.forName("myclass").newInstance())

where $foo can be any existing reference.

But this is really not a very clean coding style... Also, the class you
load must have a default constructor (otherwise it is still possible but
more complex).

By the way, dev people, why is this issue only scheduled for 1.6? Will's
patch seems to be ready in
http://issues.apache.org/jira/browse/VELOCITY-179 and backward
compatible with proper default configuration value.

  Claude


Le vendredi 29 septembre 2006 à 10:27 -0400, sandesh makam a écrit :
> hi,
>   Can any body tell me how i can call a class in a velocity template.
>  I am trying to write a template which call a class that allows me to build
> a tree.
> 
> thankyou


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to