views:

91

answers:

1

Hi, In a controller, I have populated a map that has a string as key and a list as value; in the gsp, I try to show them like this:

<g:each in="${sector}" var="entry" >
  <br/>${entry.key}<br/>
  <g:each in="${entry.value}" var="item" >
    ${item.name}<br/>
  </g:each>
</g:each>

The problem is that item is considered as string, so I get the exception

Error 500: Error evaluating expression [item.name] on line [11]:
groovy.lang.MissingPropertyException: No such property: name for class: 
java.lang.String

Any hints on how to fix it other than doing the find for the item explicitly in the gsp ?

A: 

I did the poc which works fine for me

class Item{   
     String name 
}

List items = [new Item(name:"laptop" , new Item(name:"mouse")]

Map sector =[:]

sector.manager = items

sector.manager.each{item->

println item.name

}

Even If it doesn't work, Try declaring Map sector as

Map < String, List < Item > > sector =[:]

Amit Jain
Thanks for your answer but the problem happens in the view with the gsp tags, not in the controller.
xain