Grails 将控制器中的参数传递给 selectBox
嘿。我有这个控制器:
def participated_favourite = {
def user = User.get(1)
def conferenceUser
def original = ConferenceUser.findAllByUser(user)
def temp = ConferenceUser.findAllByUserAndIsFavourite(user, 1) // all conferenceUser filtered by User
def priz = [:]
def subm = [:]
...
...
[temp: temp, priz: priz, subm: subm, orig: original]
}
我现在希望能够在选择框中选择“原始”传递的会议列表(在 Participated_favourite.gsp 中)。
我怎样才能做到这一点?
<g:select name="" from="${orig.list()}" optionKey="id" value="" />
这给了我一个不应该的空选择框。因为我的数据库里只有一条记录。我做错了什么? 提前致谢,
EDIT______________
我在同一个 gsp 中有以下内容:
<g:each var="it" in="${orig}">
<table cellspacing="2">
<tbody><tr>
<th>Name</th>
</tr>
<tr>
<td class="color1">${it.conference}
</td>
</tr>
</tbody>
</table>
</g:each>
它是 p+printing 值。所以我不知道选择中有什么问题..
Hey. I have this controller:
def participated_favourite = {
def user = User.get(1)
def conferenceUser
def original = ConferenceUser.findAllByUser(user)
def temp = ConferenceUser.findAllByUserAndIsFavourite(user, 1) // all conferenceUser filtered by User
def priz = [:]
def subm = [:]
...
...
[temp: temp, priz: priz, subm: subm, orig: original]
}
I want now to be able to select in a selectBox, the list of conferences passed by 'original' (in the participated_favourite.gsp).
How can i do that?
<g:select name="" from="${orig.list()}" optionKey="id" value="" />
This is giving me an empty select box which shouldnt. because there is one record in my database. What am i doing wrong?
Thanks in advances,
EDIT______________
I have in same gsp the folowing:
<g:each var="it" in="${orig}">
<table cellspacing="2">
<tbody><tr>
<th>Name</th>
</tr>
<tr>
<td class="color1">${it.conference}
</td>
</tr>
</tbody>
</table>
</g:each>
And it is p+rinting the values. So i dont know what is the problem in the select..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试为
name
属性指定一个值。---编辑-----
尝试以下方法进行故障排除:
这有效吗?
如果是这样,怎么样?
Try giving the
name
attribute a value.---EDIT -----
Try the following to troubleshoot:
Does this work?
<g:select from="${ConferenceUser.list()}" />
If so, how about this?
<g:select from="${ConferenceUser.list()}" optionKey="id" />
使用
use