结合枚举的命令我有一个类:数据Grails中
class User {
Set<Foo> foos = []
}
其中Foo
是一个枚举:
class Foo { A, B, C, D}
我有User
def someAction = {User user ->
// impl omitted
}
我在GSP中创建了一个多选择
<g:select name="foos" multiple="true" from="${Foo.values()}"/>
但是,当我提交表单选定的值不获取绑定到User
命令对象的foos
财产。我究竟做错了什么?
好奇 - 如果您将用户更改为拥有单个“Foo”(而不是“Set”),那么它是否正确绑定,然后选择单个值? –
@Rob - 是的,工作正常。我认为如果我在选择中的每个选项中添加了索引,那么集合枚举就可以工作,但我想不出任何无痛的方式来做到这一点 –
[Grails绑定集合枚举](http:// stackoverflow .com/questions/7216297/grails-bind-collection-enum) – luvieere