geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dillon <>
Subject How to get Velocity to work better with Groovy?
Date Thu, 08 Feb 2007 23:45:32 GMT
No answer from the velocity folks, so I'll try here...

Hi, I'm trying to get Velocity to work better with Groovy objects,  
like Expando and other more dynamic objects.

In groovy one can:

def data = new Expando() = 'bar'

This will dynamically create new properties on the object 'data'.

But, if you pass that 'data' object to Velocity in a context, then a  
template like:


Will simply render:


As it was unable to de-reference the 'foo' property.

  * * *

I like Groovy, and I like Velocity, but I would like them to play  
better together.

Is there any mechanism in Velocity to get more control over how it  
evaluates bits like "$"?  Or perhaps, if 'data' is in the  
context, then more control over how Velocity finds the 'foo' property  
of the object which is bound to the 'data' name?  I guess the same  
would also go for finding methods on objects bound in the context.

Any help is appreciated.  Thanks,


View raw message