我需要填充搜索功能的下拉列表。我遇到了一些困难,因为该表具有复合ID。我相信我必须引用两个外键但不确定如何。
Oracle 11g本地和READ ONLY gGrails 2.3.3
这是我的带有复合键的域
static belongsTo = [trustee:Trustee, committees:Committees]//
static constraints = {
position nullable:true
type nullable:true
}
static mapping = {
table 'BOT_TRUSTEE_COMMITTEES'
version false
id composite: ['trustee','committees']
trustee column:'TRUSTEE_ID'
committees column: 'COMMITTEE_ID'
position column:'POSITION'
type column:'TYPE'
}
以下是调用我的下拉列表的视图模板
<tr>
<td>
<label for="hospital">
<g:message code="hospitals.hospitalName.label" default="Hospital:" />
</label>
</td>
<td>
<g:select name="hospitalId" from="${Hospitals.list()}" optionKey="id" required="" optionValue="hospitalName" noSelection="['null':'-Choose a hospital-']"/>
</td>
</tr>
<!-- Committee drop down list -->
<tr>
<td>
<label for="committee">
<g:message code="committees.description.label" default="Committee:" />
</label>
</td>
<td>
<g:select name="committeesId" from="${Committees.list()}" optionKey="id" required="" optionValue="committeeName" noSelection="['null':'-Choose a committee-']" />
</td>
</tr>
<!-- Type drop down list -->
<tr>
<td>
<label for="type">
<g:message code="membership.type.label" default="Type:" />
</label>
</td>
<td>
<!-- input drop down list for type here -->
<g:select name="trusteeType" from="${TrusteeMembership.list()}" optionKey="id" required="" optionValue="type" noSelection="['null':'-Please select one-']"/>
</td>
</tr>