velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Glass-Husain <wgl...@forio.com>
Subject Re: Putting key/value pair into hashmap from velocity template
Date Wed, 19 Jul 2006 16:45:39 GMT
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: apache@recks.org
> 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: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>     
>
>   

-- 
Forio Business Simulations

Will Glass-Husain
phone (415) 440-7500 x89
mobile (415) 235-4293
wglass@forio.com
www.forio.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message