views:

55

answers:

2

This is in my gsp and it doesn't work

<g:select name="head.id" from="${com.hive.Persons.findAllByFirstname(${variable})}" optionKey="id" value="${organizationInstance?.head?.id}"  />

I think that the main reason is that I am nesting ${}. How can I accomplish this. ${variable} is a string passed from the controller.

thanks!

+1  A: 
  1. Your from attribute should be populated in controller on the server side.
  2. As a dirty hack you can use the following code:

<g:findAll in="${com.hive.Persons.findAll()}" expr="it.firstname == ${variable}">

  <option>${it.firstname}</option>

</g:findAll>

uthark
+3  A: 

You don't need the nested ${}

<g:select name="head.id" from="${com.hive.Persons.findAllByFirstname(variable)}" optionKey="id" value="${organizationInstance?.head?.id}"  />

should work.

leebutts