Ah. Well, if the result returned by getBar() is an object type under your control, then with 1.6-beta2, you can have it implement this interface:
http://velocity.apache.org/engine/devel/apidocs/org/apache/velocity/runtime/Renderable.html which allows rendering that doesn't go through toString(). If the class of that is not under your control or you don't like the above method, then you may be able to achieve your result via a custom Uberspect implementation. http://velocity.apache.org/engine/devel/apidocs/org/apache/velocity/util/introspection/Uberspect.html The default setting in the velocity.properties is: runtime.introspector.uberspect = org.apache.velocity.util.introspection.UberspectImpl the easiest thing is usually to replace that with a subclass of UberspectImpl. and with 1.6-beta2, there is support for chaining and linking Uberspects as well. http://velocity.apache.org/engine/devel/apidocs/org/apache/velocity/util/introspection/ChainableUberspector.html If you went the custom Uberspect route, then you should be able to turn a getBar() call into something else. On Fri, Nov 7, 2008 at 7:17 AM, James Carr <[EMAIL PROTECTED]> wrote: > Thanks, but that doesn't quite do what I need... it seems that it only > gets the value returned by the method call and has no reference to the > object the call was made on. For example, if my template has > > $foo.bar > > I just get the following: > "$foo.bar" > "Some string returned by method bar" > > Is there any way to get a reference to $foo in this case and intercept > the result returned by getBar()? > > Thanks, > James > > -----Original Message----- > From: Nathan Bubna [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 06, 2008 12:16 PM > To: Velocity Users List > Subject: Re: Filters? > > Sounds like something that the ReferenceInsertionEventHandler might be > able to do: > > http://velocity.apache.org/engine/devel/developer-guide.html#Configuring > _Event_Handlers > http://velocity.apache.org/engine/devel/apidocs/org/apache/velocity/app/ > event/ReferenceInsertionEventHandler.html > > On Thu, Nov 6, 2008 at 6:28 AM, James Carr <[EMAIL PROTECTED]> wrote: >> Hi All, >> >> >> >> Is there some kind of way in the velocity API to implement filters > that >> can operate on objects on the context? Specifically, say object person >> is on the context, if person.name is called, and the getName() method >> has an annotation on it, I want to be able to transform the value >> displayed on the rendered output. >> >> >> >> Is this possible? >> >> >> >> Thanks, >> >> James >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
