velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Townson, Chris" <C.Town...@nature.com>
Subject RE: Static java classes
Date Tue, 08 May 2007 08:50:33 GMT
alternatively, you could simply create a bean wrapper that just delegates to the static class.
An instance of the bean could then be put into the context.

Chris 

> -----Original Message-----
> From: mailmur [mailto:mailmur@yahoo.com] 
> Sent: 07 May 2007 20:20
> To: Velocity Users List
> Subject: Re: Static java classes
> 
> 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
> 

********************************************************************************   
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
not the original intended recipient. If you have received this e-mail in error
please inform the sender and delete it from your mailbox or any other storage
mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
liability for any statements made which are clearly the sender's own and not
expressly made on behalf of Macmillan Publishers Limited or one of its agents.
Please note that neither Macmillan Publishers Limited nor any of its agents
accept any responsibility for viruses that may be contained in this e-mail or
its attachments and it is your responsibility to scan the e-mail and 
attachments (if any). No contracts may be concluded on behalf of Macmillan 
Publishers Limited or its agents by means of e-mail communication. Macmillan 
Publishers Limited Registered in England and Wales with registered number 785998 
Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS   
********************************************************************************

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


Mime
View raw message