我有这个关于<g:select>
标签的问题。我的 view.gsp 上有这个声明,
<g:select id='selectedId' name='selectedValue' from='${selectedList}'
optionKey='tblColumn' value='${element.value}'/>
并拥有此控制器和域模型:
// Controller
def element = Model.get(params.id)
render(view:'view.gsp', model:[element: element, selectedList: Value.list()]
// End-Controller
//[Domain Model]: Model
class Model {
String name
Value value
// constraints
}
//End-[Domain Model]: Model
//[Domain Model]: Value
class Value {
String tblColumn
// constraints
String toString() { "${this.tblColumn}" }
}
//End-[Domain Model]: Value
问题是,一旦页面加载,我无法让<g:select>
标签将 的值显示为标签${element.value}
上的选定值。<selected>
当我查看页面源代码时,此代码行返回:
<select id="selectedId">
<option value='/* the value by the optionKey */'>/* the value */</option>
<option value='/* the value by the optionKey*/' selected='selected'>/* the value to be displayed */</option>
</select>