velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mailmur <>
Subject Re: Static java classes
Date Mon, 07 May 2007 19:19:40 GMT
Once I had to publish ErrorCodes "constants" to
templates (ErrorCodes.INVALID_KEY etc...). Use
FieldMethodizer wrapper to publish constant fields.

ctx.put("ErrorCodes", new

And if you need access to static methods then can
always add a default constructor that does nothing.

ctx.put("Utils", new Utils());

If you dont want to add constructor to a pure static
class, FieldMethodizer may work for static methods as
well. I never tried it.

--- Sebastian Gumpold <>

> Hi all!
> Is it possible to use static classes in a Velocity
> template?
> When using
> context.put("bla", instanceOfBla);
> a concrete instance of a class is needed, so this of
> course doesn't work 
> for a static class.
> Thanks a lot,
> Sebastian

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

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

View raw message