【发布时间】:2013-11-12 14:57:39
【问题描述】:
我在保存来自两个域类的表单值时遇到问题
一类是
class Ip {
String inetAddress
String dns
String os
String toString(){
"${inetAddress}"
}
Hoster hoster
static constraints = {
....
第二个就是
class Hoster {
static HOSTER_OPTIONS = ["Name1", "Name2", "Name3"]
String name;
String toString(){
"${name}"
}
List ips = new ArrayList()
static hasMany = [ips : Ip]
static constraints = {
name(unique: true, blank: false, inList: HOSTER_OPTIONS)
}
我有一个控制器,用于处理来自表单的数据
def systems = new Ip()
systems.inetAddress = params.ip
systems.dns = params.dns
systems.os = params.os
systems.hoster.name = params.hoster
def result = systems.save(flush: true, failOnError: true)
但我没有管理好数据已保存。
【问题讨论】:
标签: grails grails-2.0 grails-domain-class grails-controller