如何在GSP中选择空(非空)标签中的第一个值?
这是我的域类 Incident
class Incident {
String status
Usergroup assignmentGroup
static hasMany={usergroups:Usergroup}
}
我想按分配组查找所有事件。我正在使用 GORM 标准,
这是 searchIncident.gsp
<tr class="prop">
<td valign="top" class="name">
<label for="assignmentGroup"><g:message code="incident.assignmentGroup.label" default="Assignment Group" /></label>
</td>
<td valign="top" class="value ${hasErrors(bean: incidentInstance, field: 'assignmentGroup', 'errors')}">
<g:select id="groupSelect" name="assignmentGroup.id" from="${app.Usergroup.list()}" optionKey="id" value="" />
</td>
</tr>
<tr class="prop" >
<td valign="top" class="name">
<label for="status"><g:message code="incident.status.label" default="Status" /></label>
</td>
<td valign='top' class='value'>
<g:select name='status' from='${[""] + new Incident().constraints.status.inList}'>
</g:select>
</td>
</tr>
在我的选项标签中,我必须选择第一个值为空(不为空)。
Here is my domain class Incident
class Incident {
String status
Usergroup assignmentGroup
static hasMany={usergroups:Usergroup}
}
I want to find all incidents by assignmentGroup.I am using GORM criteria for this
this is searchIncident.gsp
<tr class="prop">
<td valign="top" class="name">
<label for="assignmentGroup"><g:message code="incident.assignmentGroup.label" default="Assignment Group" /></label>
</td>
<td valign="top" class="value ${hasErrors(bean: incidentInstance, field: 'assignmentGroup', 'errors')}">
<g:select id="groupSelect" name="assignmentGroup.id" from="${app.Usergroup.list()}" optionKey="id" value="" />
</td>
</tr>
<tr class="prop" >
<td valign="top" class="name">
<label for="status"><g:message code="incident.status.label" default="Status" /></label>
</td>
<td valign='top' class='value'>
<g:select name='status' from='${[""] + new Incident().constraints.status.inList}'>
</g:select>
</td>
</tr>
In my option tag i must select the first value empty(not null).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解了,您需要包含 noSelection 属性,如下所示:
有关更多信息,请参阅此处的 grails 文档: http://grails.org/doc/latest/ref/Tags/select.html
吉姆
If I've understood, you need to include the noSelection attribute, as in:
See the grails docs here for more: http://grails.org/doc/latest/ref/Tags/select.html
Jim