g:选择 - 显示值

时间:2012-06-18 03:24:52

标签: html grails

我对<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>

0 个答案:

没有答案