Hi Matthias--

There's no magic.  If there are parens, it assumes it is a method call

$abc.foo("data")

calls the "foo" method with the argument "data".

$abc.foo

would call either getFoo(), getfoo()  or (for a Map) get("foo")

WILL

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.

















-------- Original-Nachricht --------
Datum: Wed, 19 Jul 2006 17:00:13 +0200
Von: [EMAIL PROTECTED]
An: Velocity Users List <velocity-user@jakarta.apache.org>
Betreff: Re: Putting key/value pair into hashmap from velocity template

try without the square brackets...

;) Christoph

Matthias Hendler wrote:
Hello,

I try to put a key/value pair to a hashmap from velocity template.

First I put a new hashmap object into velocity context named "myMap".
In my templates I can write:
...
$myMap.clear()
Size: $myMap.size()
...
The above works fine. Now I want to put a key/value pair into the
hashmap using the method put(object, object).
So I wrote:
...
${myMap.put(["123", "test"])}
               ^             ^
...
And I get an exception: "${myMap.put(["123", "test"])} is not a valid
reference."
What's wrong?

Thanx Matthias









---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Forio Business Simulations

Will Glass-Husain
phone (415) 440-7500 x89
mobile (415) 235-4293
[EMAIL PROTECTED]
www.forio.com

Reply via email to