velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veerabahu subramanian <veech...@gmail.com>
Subject Property to turn off velocity from echoing reference
Date Mon, 23 Feb 2009 08:39:33 GMT
Hi All,
I am trying to do a collection manipulation in Velocity, i.e. I will check
for existence of key in a HashMap and if it exists I will append the current
value if not I will add the current value.
The template file for this is as below

[code]
#set($dummymap={})
#foreach($listItem in $list)
#if($dummymap.get($listItem))
##if the value exists in the map
#set($existingvalue=$dummymap.get($listItem))
#set($existingvalue="${existingvalue},$listItem")
#set($dontuse=${dummymap.put($listItem,$existingvalue)})
#else
$!{dummymap.put($listItem,"1")}
#end
#end
Dummy map is $dummymap
[/code]

In this I have two doubts
  1. If I didn't assign the return value
of ${dummymap.put($listItem,$existingvalue)} to a variable then the return
value is rendered as a output. Is there any property to turn off this
behavior. I did a search for the same also checked the velocity.properties
in latest build but I don't find a relevant one.
 2. Will dummymap treated as a string internally by velocity. Mainly I want
to know will there be a performance improvement if i do the above logic
inside "#foreach($listItem in $list) " in Java instead of template file

Thanks,
Veerabahu

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