velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neal Smith" <>
Subject RE: Struts and I18N
Date Thu, 25 Aug 2005 19:31:01 GMT
Oi?  That's not very nice...  I was having a very hard time interpreting that last "sentence"
from the previous email.

I completely understand how it works in the normal servlet context.  You have to admit there
is a lack of good doc on using this "standalone" as you put it.

I appreciate the pointers on where to look.  If I go ahead and do the hack, then I might as
well pull Velocity out altogether.  I was leaning towards that before I decided to give it
one more try.  Hopefully, these resources will have the answer.


-----Original Message-----
From: Nathan Bubna [] 
Sent: Thursday, August 25, 2005 3:14 PM
To: Velocity Users List
Subject: Re: Struts and I18N

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
you may be able to create an appropriate context for your emails that could include an initialized

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:

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

View raw message