velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: Using generic tools outside of webapp
Date Mon, 22 May 2006 15:03:57 GMT
On 5/22/06, James Shaw <js102@zepler.net> wrote:
> I've seen some examples of using velocity generic tools in a webapp,
> but none using them standalone.
>
> I'm trying to use DateTool in a template.  While the docs say I can
> use it "as you would any other POJO" I'm not sure how exactly.  AIUI,
> I shouldn't require a toolbox.xml file as this is part of
> VelocityView, is this right?

correct, no toolbox is required for using generic tools.  you simple
instantiate the tool, do any configuration you want manually, put it
into the context, then use it in the template as you would anywhere
else.

> Some examples or documentation would be
> appreciated ;-)

here's a quick example:

== java class that prepares your VelocityContext ===
DateTool date = new DateTool();
Whatever anyOtherPojo = new Whatever();

context.put("date", date);
=======================================

== template being processed ===
$date.short_time
$anyOtherPojo
=========================

Does that help?

> Thanks in advance
> James Shaw
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message