I'm using velocity 1.6.4 as packaged with Solr. So everything is going through the VelocityResponseWriter which is also part of Solr. I was adding objects to the context using response.add("name" value); and in the VelocityResponseWriter the Solr response is added to the VelocityContext but it appears as though the object goes through some serialization prior to getting added. I just made my own version of VelocityResponseWriter and it solved the issue. Thanks for your help.
-----Original Message----- From: Nathan Bubna [mailto:nbu...@gmail.com] Sent: Wednesday, June 01, 2011 10:48 PM To: Velocity Users List Subject: Re: Custom Java Object stored in Velocity Context Well, i've got no problems getting Velocity to call public methods on instances of publicly declared classes. Got any more info you can share? Like the class in question? Velocity version? Log messages? Anything? On Wed, Jun 1, 2011 at 7:53 PM, Logan Stinger <lstin...@bluelid.com> wrote: > The class is very simple right now, public class with 5 public getters and setters. Nothing else to it. I've tried sticking a few other classes in the context to test them. I have been unable to get anything but the toString representation of any of them. > > On Jun 1, 2011, at 5:15 PM, Nathan Bubna wrote: > >> The class of the object and the method itself must be declared public. >> >> On Wed, Jun 1, 2011 at 1:38 PM, Logan Stinger <lstin...@bluelid.com> wrote: >> >>> I have the following code: >>> >>> >>> >>> List<ICODocument> history = >>> repository.getDocumentHistoryForId("8B2F2F53-7DEA-45B6-84BA-60F2FA11 >>> F07D"); >>> >>> context.put("documentHistory", history); >>> >>> >>> >>> Then in my notes.vm file I have the following: >>> >>> #foreach($doc in $response.response.get("documentHistory")) >>> >>> $doc >>> >>> #end >>> >>> >>> >>> The rendered output is what I would expect. However, I dont want >>> to see the toString() representation of my object. I want to see >>> the value of a particular method call on my object. >>> >>> >>> >>> So I changed my notes.vm to be this: >>> >>> #foreach($doc in $response.response.get("documentHistory")) >>> >>> $doc.isMax() >>> >>> #end >>> >>> >>> >>> In this case my rendered output is simply: >>> >>> $doc.isMax() $doc.isMax() >>> >>> >>> >>> I was under the impression that I could add any java object to the >>> velocity context and call any method on that object in my velocity >>> template. Am I misunderstanding? >>> >>> >>> >>> >>> >>> *Logan Stinger* >>> >>> *[image: Description: bluelid_logo_small]* >>> >>> * * >>> >>> (515) 281-6702 >>> >>> (515) 822-8212 >>> >>> lstin...@bluelid.com >>> >>> >>> >>> >>> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org > For additional commands, e-mail: user-h...@velocity.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org