History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-1323
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Graeme Rocher
Reporter: nacho
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Grails

g:select doesn't generate default selection

Created: 26/Jun/07 08:26 AM   Updated: 29/Jun/07 05:53 AM
Component/s: TagLib
Affects Version/s: 0.5.6
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Ubuntu, jdk6_01


 Description  « Hide
g:select is supposed to render a "selected='selected'" or alike for the element in 'from' attribute value that equals to the 'value' attribute value, as seen in docs: http://grails.codehaus.org/Tag+-+select . But when I do so nothing happens. The tag seems to ignore de value attribute.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jeff Brown - 26/Jun/07 05:50 PM
nacho,

Can you show a snippet of your relevant code? I can't reproduce the problem.

Thanks.

jb


Jason Morris - 29/Jun/07 05:53 AM
I have just seen the same thing, but it only seems to be a problem when you use the optionKey attribute. If I don't use optionKey and supply an instance of the object from the list, it works fine. i.e.

from="${myobjectlist}" value="${myobject}"

But if I use

from="${myobjectlist}" optionKey="id" value="${myobject}"

I get a ClassCastException because I think it is expecting value attribute to be of the same type as optionKey attribute, so you cannot pass the whole object to value. So I switched to

from="${myobjectlist}" optionKey="id" value="${myobject.id}"

That gets rid of the ClassCastException, but there is no "selected" attribute on any of the resulting <option> tags in the HTML. I tried it wil hard-coded id values too any still no joy.

Hope that helps, Jason

(BTW, this is my first post in this forum, and can I say that Grails ROCKS!)