velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Re: template encodings
Date Sun, 15 Jul 2001 13:28:34 GMT
Jonathan Revusky wrote:
> I have the Velocity developer guide doc in front of me and I'm looking
> at the section entitled "Template Encoding for Internationalization".
> There is a method called mergeTemplate that takes the encoding as an
> argument.
> My belief is that once you figure out the desired locale, and call
> response.setLocale(myLocale) that simply by writing to the Writer object
> returned by response.getWriter() that it will (should) be encoded
> appropriately.

I am not sure what you are getting at - but note that the encoding
argument to mergeTemplate() is the encoding of the *template*, not the
output.  The encoding of the output stream is something else entirely.  

mergetTemplate() is a utility method provided by the Velocity helper
class to allow you to easily render a template.  The usual mechanism is
to use the pattern of 

Template t = getTemplate( name, encoding );
t.merge( context, writer);

so you see, fundamentally the two steps are distinct.  You could merge
the same template repeatedly with different writers that use different
encodings, if you wished.

> IOW, this should really be the realm of responsibility of the underlying
> servlet engine AFAICS. (Though, that said, I *think* that extra i18n
> hook was added as of the 2.2 servlet spec. I explicitly say that Niggle
> requires >2.2 servlet engine.)

Like I said, this encoding flag is to specify the encoding of the
template for input.  For ouput, you are right - it's up to you.  I will
make this clearer in the docs.
> This is basically the assumption I have gone on in the Niggle framework.
> Funny thing, judging from servlet logs, I get a lot of downloads from
> Japan and Taiwan. And they keep coming back when I announce a new
> version. But I get no feedback from these people as to whether this
> actually works!
> In other matters, there is one person who I know to be subscribed to
> this list who expressed interest in using Niggle in conjunction with
> Velocity. (At the time, only Freemarker and WebMacro were supported.)
> There is a preview that allows usage of Velocity as the template engine
> available here:

That's great.

> If you simply read the various references to webmacro and mentally
> substitute in velocity, you should be able to get it working with
> velocity. There are sample velocity templates for the mini-rolodex
> sample app. I will have to patch up the docs before I announce this.
> (Probably before mid-week.)

Very cool.  Let us know.


Geir Magnusson Jr.                 
System and Software Consulting
Developing for the web?  See
You have a genius for suggesting things I've come a cropper with!

View raw message