velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: Global Context Objects?
Date Sat, 20 Oct 2007 14:44:45 GMT
You can either use VelocityTools (you'll probably find VelocityTools 2
easier, though it's in alpha still) or else just create a global
VelocityContext instance and chain all other context objects to it:

//pseudo-code
VelocityContext global = new VelocityContext();
fillGlobalContext(global);
for (SomeXMLOrOtherItem foo : thingstoprocess) {
    // chain the local and global contexts
    VelocityContext local = new VelocityContext(global);
    processXMLOrOtherItem(foo, local);
}

On 10/19/07, jnusaira <online@resonatinglight.com> wrote:
>
>
> Hi,
>
> I am using Velocity for templating of some XML and other items. (not UI
> front end)
>
> So I have a singleton containing the VelocityEngine.
>
> I need to pass in some utility classes to it (like a DateUtil and some
> custom ones). However I'd like to initialize it at the begining on engine
> creation. Is there a way of doing that??
>
> Obviously i can just attach it to the context objects when passing through
> but i'd prefer not to.
>
> Thanks
>
> --
> View this message in context: http://www.nabble.com/Global-Context-Objects--tf4655200.html#a13301024
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Mime
View raw message