ArrayList and Map problem in grails

Posted by xain on Stack Overflow See other posts from Stack Overflow or by xain
Published on 2010-04-12T16:14:05Z Indexed on 2010/04/12 16:23 UTC
Read the original article Hit count: 179

Filed under:
|
|
|

Hi, I have a service that contains a map:

static Map cargosMap = ['1':'item1','2':'item 2','3':'item 3']

that is returned via a method in the service:

 static Map getCargos() {
    [cargosMap]
 }

A controller calls it like this:

def mform = {

    Map cargos = empService.getCargos()

    [cargos:cargos]
}

In the gsp, I have the select:

<g:select name="cg1" from="${cargos}" />

But I'm getting the exception:

 Error 500: Executing action  ....caused exception: 
   org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object
   ...  
   with class 'java.util.ArrayList' to class 
  'java.util.Map'

Any clues ? Thanks

© Stack Overflow or respective owner

Related posts about grails

Related posts about array