Take the 2-minute tour ×

I have the following velocity code.

#foreach($content in $list)
   #set($map = {$content.categoryName:[]})

   #foreach($child in $children)
      // I want to add values to $map.$content.categoryName

I would like to add values to $map.$content.categoryName. I tried

$map.$content.categoryName.add(values here) 

but it didn't work. I also tried

$map[$content.categoryName].add(values here)

But it still didn't work. Could someone please help me with this problem.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It's java, not javascript:


share|improve this answer
No :) But i'm just very used to people confusing the two in both syntax and server vs client side render-time. So i make totally uncalled-for assumptions like that sometimes. My apologies! –  Nathan Bubna Apr 29 '11 at 14:38
// no..no need to apologies. I just looked up my question and i was like.. "oh..did I post a wrong question..?" –  Moon May 1 '11 at 2:18
Actually, you are adding values to a list, not a map. The map just happens to be in a map. –  Will Glass Jun 25 '11 at 1:13

Your Answer


