Thanks for responding Jian, I would not call what I am trying to doing complicated, I'm just calling a method! I either call the method or have to break the DRY principle and rewrite it in vtl!
Many other code elements access ApplicationConstants. I should know this but I am wondering if adding extends Object to it will require an object being created...I guess not... Cheers, Tom. On 25 May 2010 15:00, jian chen <[email protected]> wrote: > Hi, Tom, > > I am also using Velocity 1.4 currently. I tend to avoid complicated > variable > assignment like #set($count = $object.method(...)). > > Why not just pass an object? It is not costly anyway: > context.put("ApplicationConstants", new com.myco.ApplicationConstants()); > > You can also use the FieldMethodizer on the object. > > > > > > Jian > www.JiansNet.com > Built with Java and Velocity Engine > > On Tue, May 25, 2010 at 5:30 AM, boardtc <[email protected]> wrote: > > > We are stuck with Velocity 1.4 at the moment. > > > > I have a java public final class ApplicationConstants which is full of > > final static constants, e.g. COUNT and a static string method, returnView > > which takes a string, e.g "test". I add it to my context like > > context.put("ApplicationConstants", new > > FieldMethodizer("com.myco.ApplicationConstants")); > > In my template > > #set($count = $ApplicationConstants.COUNT) > > works but > > #set($count = $ApplicationConstants.returnView("test")) > > does not. > > > > Any advice appreciated. > > > > Cheers, > > > > Tom. > > >
