geronimo-user mailing list archives

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

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()
data.foo = '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:

<snip>
$data.foo
</snip>

Will simply render:

<snip>
$data.foo
</snip>

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 "$data.foo"?  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,

--jason


Mime
View raw message