I have seen it happen, and I just automatically compensate. Maybe it
was in an older version.
Barbara Baughman
Systems Analyst
Information Security
972-883-2157
On 6/3/11 10:55 AM, Nathan Bubna wrote:
On Fri, Jun 3, 2011 at 8:50 AM, Barbara Baughman<[email protected]> wrote:
You can call any public method from any public class. The final Velocity
rendering will always be the toString version of the output. I can't think
of a Velocity application that would not, in the end, need a String
representation, so your complaint about the toString rendering doesn't make
sense to me.
However, the toString rendering has caused me some problems with Velocity
when I call the output of one method within another method.
For example:
#if ($account.isActive($user.usertype))
In this case, the isActive method expects an int value, and the getUsertype
method returns an int. However, $user.usertype is rendered by Velocity as a
String, which causes this statement to fail.
Barbara, that shouldn't happen. Velocity should not be converting
$user.usertype to a String unless it is rendering it. If it is being
passed to a method it should look for isActive(int), not
isActive(String).
This can either be handled by
having a public overload method that takes a String, or a method that will
convert a String to the class expected by the calling method. Or create a
wrapper class that includes both the account and user objects and a method
that determines the isActive status knowing the account and user
information. I'm sure other solutions can come to mind.
I don't know if this is at the root of your question, but I thought I'd
mention this.
Barbara Baughman
Systems Analyst
Information Security
972-883-2157
On 6/1/11 9:53 PM, Logan Stinger 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<[email protected]>
wrote:
I have the following code:
…
List<ICODocument> history =
repository.getDocumentHistoryForId("8B2F2F53-7DEA-45B6-84BA-60F2FA11F07D");
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 don’t 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
[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]
---------------------------------------------------------------------
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]