velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apa...@recks.org
Subject Re: Putting key/value pair into hashmap from velocity template
Date Wed, 19 Jul 2006 17:09:05 GMT
as Will said, there is no magic in calling methods
from within a velocity template - apart from the
convenience getFoo(), getfoo() or get("foo")
additions.

I suggest you check your class. The class *and* the
put(x,y) method must be public. And as your example shows
must take two strings parameters. The Velocity
introspector is intelligent enough to up-cast your
strings to objects if the method takes Object as
parameters.

Try the output of $myMap.class.name to be sure you
are looking to the object you are expecting.

Cheers,
Christoph

Matthias Hendler wrote:
> Thanx Chris,
> 
> but this doesn't solve the problem. :(
> It's  still the same error.
> I also tried to use the method set(index, object) from arraylist, but this also doesn't
work.
> 
> I guess that velocity does "some magic" and don't calls the put-method from hashmap or
the set-method from arraylist.
> 
> I have verified both tests by calling the methods clear() and size() on hashmap and arraylist
to be sure, that the objects exists in the velocity context.
> 
> I have found at http://www.freebok.net/help/velocity4.html the following  example:
> $sisyphus.pushRock()
> ## Velocity assumes I mean $sisyphus.getRock()
> Its not discussed in detail what the author meant by his example, but I wonder how velocity
assumes method calls.


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message