velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mailmur <mail...@yahoo.com>
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
FieldMethodizer(ErrorCodes));

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 <sebastian.gumpold@sbs.co.at>
wrote:

> 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 
http://mail.yahoo.com 

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


Mime
View raw message