velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <>
Subject Re: Struts and I18N
Date Thu, 25 Aug 2005 19:14:01 GMT
On 8/25/05, Neal Smith <> wrote:
> Re: Formatting Numbers, etc. -  I had read that, but being so wrapped up in Struts stuff,
I completely forgot about that.
> Re: VelocityContext - Hmmm...  This is where I thought I was going to have an issue.
 The existing code is just creating a new VelocityContext.  I'm not sure I understand all
of your last question.  I see by the doc, that VelocityViewServlet has a protected createContext(),
but how do I get hold of that context?  Is the request holding the VelocityViewServlet for
me or do I need to create my own?

oi...  well, servlets exist to handle servlet requests.  requests
don't hold servlets.  :)  whether or not a servlet handles a
particular request depends on the webapp configuration in your web.xml
file.  typically, the VVS (VelocityViewServlet) will only handle a
request if it is a request for a velocity template.  (Tim Colson made
a nice graphic illustration of this for our VelocityStruts docs--

when the VVS gets a request, it creates a special ChainedContext for
it and attaches a "toolbox".  The contents of the toolbox are
determined by your toolbox.xml file (your web.xml should tell the VVS
where this file is).

so, all this is to say...  it doesn't seem likely that the VVS is
getting involved with the HTTP request that is creating these emails. 
i'm really not at all sure the best way to make that happen.  so it's
hard to say where to go from here.  if you search the archives for
"standalone toolbox" or look into the ServletToolboxManager class
you may be able to create an appropriate context for your emails that
could include an initialized MessageTool.

or, you may just want to hack the MessgeTool to make it so that you
can manually hand it the locale and resource bundle and place it in
your simple context.  this might be the easiest way to go for now. 
however, in the long run, the flexibility of full toolbox support
might be worth it.

> Thanks,
> Neal
> P.S.  Here is the code where we create the VelocityContext:

yeah, that's just creating a basic empty context.  no special
VelocityTools powers. :)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message