You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Mohsen Saboorian <mo...@gmail.com> on 2006/09/14 06:13:17 UTC

How to use velocity tools from a non-web-application

Hi,
I'm using Velocity as an embedded template engine for some code generation
in an application. I tried hard to convert a String to an Integer value (so
that I can use it in a simple calculation), but could not do that either
when wrapped attributes in a class with a toInteger() method.

Anyway, I've noticed that there is a tool for that (generic math tool). Is
it possible to use it in my app (the sample projects on the download archive
of velocity-tools are all web application who refer to an XML file through
web.xml). How can I refer to toolbox.xml?

Thanks.
-- 
View this message in context: http://www.nabble.com/How-to-use-velocity-tools-from-a-non-web-application-tf2269519.html#a6299220
Sent from the Velocity - User forum at Nabble.com.


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


Re: How to use velocity tools from a non-web-application

Posted by Nathan Bubna <nb...@gmail.com>.
For now, Manish is right.  Just do context.put("math", new
MathTool());.  I am planning to add a "standalone" toolbox loader for
automatic tool loading in non-webapp situations, but i haven't gotten
around to that yet.

On 9/13/06, Mohsen Saboorian <mo...@gmail.com> wrote:
>
> Hi,
> I'm using Velocity as an embedded template engine for some code generation
> in an application. I tried hard to convert a String to an Integer value (so
> that I can use it in a simple calculation), but could not do that either
> when wrapped attributes in a class with a toInteger() method.
>
> Anyway, I've noticed that there is a tool for that (generic math tool). Is
> it possible to use it in my app (the sample projects on the download archive
> of velocity-tools are all web application who refer to an XML file through
> web.xml). How can I refer to toolbox.xml?
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/How-to-use-velocity-tools-from-a-non-web-application-tf2269519.html#a6299220
> Sent from the Velocity - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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


Re: How to use velocity tools from a non-web-application

Posted by Manish <pr...@gmx.net>.
In a non web application you can simply add an instance of any required tool to 
the Velocty context & can use it in your template.

hth,
- Manish


----- Original Message ----- 
From: "Mohsen Saboorian" <mo...@gmail.com>
To: <ve...@jakarta.apache.org>
Sent: Thursday, September 14, 2006 9:43 AM
Subject: How to use velocity tools from a non-web-application


>
> Hi,
> I'm using Velocity as an embedded template engine for some code generation
> in an application. I tried hard to convert a String to an Integer value (so
> that I can use it in a simple calculation), but could not do that either
> when wrapped attributes in a class with a toInteger() method.
>
> Anyway, I've noticed that there is a tool for that (generic math tool). Is
> it possible to use it in my app (the sample projects on the download archive
> of velocity-tools are all web application who refer to an XML file through
> web.xml). How can I refer to toolbox.xml?
>
> Thanks.
> -- 
> View this message in context: 
> http://www.nabble.com/How-to-use-velocity-tools-from-a-non-web-application-tf2269519.html#a6299220
> Sent from the Velocity - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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