Reputation: 757
I'm trying to do something pretty simple, that apparently is not that simple. I have a domain class:
class Regex {
String name
String Regex
}
and another class:
class RegexRef {
int sequenceNumber
Product product
Regex regex
}
Now, in a select, I want to list the RegexRef instances, with the name of the regex as the optionValue as such:
<g:select name="regexRef.id" from="${com.mycompany.RegexRef.list()}" optionKey="id" size="5" optionValue="regex.name" value="${actionRefInstance?.regexRef?.id}" />
but this doesn't work. It throws: Exception Message: No such property: regex.name for class: com.jetheaddev.RegexRef
I can do this mis-direction in other constructs...
<g:link controller="regexRef" action="show" id="${actionRefInstance?.regexRef?.id}">${actionRefInstance?.regexRef?.regex.name.encodeAsHTML()}</g:link>
and it works fine.
Upvotes: 1
Views: 714
Reputation: 3881
With optionValue="regex.name"
the <g:select/>
is trying to retrieve the property of RegexRef as:
regexRefInstance."regex.name"
To retrieve the name property on the Regex
class do:
<g:select optionValue="${{it.regex.name}}"/>
which will run the optionValue Closure
on each entry in the list and retrieve the related name
property.
Upvotes: 2