You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by AngeloChen960 <an...@gmail.com> on 2008/01/16 04:01:12 UTC

T5: using velocity in the app

hi,

I need to use velocity's template to format an email, something like this:

 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Template t = ve.getTemplate("email.vm");
but always got :ResourceNotFoundException
any idea how to use Velocity with Tapestry 5? thanks.

A.C.
-- 
View this message in context: http://www.nabble.com/T5%3A-using-velocity-in-the-app-tp14861724p14861724.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: using velocity in the app

Posted by Hugo Palma <hu...@gmail.com>.
Your problem is not specific to Tapestry. You can use Velocity in a
Tapestry application just like you use anywhere else.

In this case, i think the problem is that your not setting the velocity
resource loader, and by default velocity tries to load the file you
provide from the current directory. I'm guessing that's not what you want.
You can see more information on this here
http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#configuring_resource_loaders

In the mean time, if for example you wanted to load the template from
the classpath you could do:

VelocityContext velocityContext = new VelocityContext();
Velocity.addProperty("resource.loader", "classpath");
Velocity.addProperty("classpath.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

Template template = Velocity.getTemplate("email/email1.vm");

AngeloChen960 wrote:
> hi,
>
> I need to use velocity's template to format an email, something like this:
>
>  VelocityEngine ve = new VelocityEngine();
>  ve.init();
>  Template t = ve.getTemplate("email.vm");
> but always got :ResourceNotFoundException
> any idea how to use Velocity with Tapestry 5? thanks.
>
> A.C.
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org