【发布时间】:2017-02-02 09:18:24
【问题描述】:
使用 Grails 域对象,我在尝试设置某些属性时偶然发现了一个问题。
var stepchild=parent.children.find{ it.id==xInt };
stepchild.metaClass.birthMom=biologicalMothersName;
parent.children.each{child->
//when it gets to stepchild no metaclass property birthMom exists....
}
也没有在引用的对象上设置自定义错误
var stepchild=parent.children.find{ it.id==xInt };
stepchild.errors.rejectValue('parent',"Not biological parent");
parent.children.each{child->
//when it gets to stepchild no errors....
}
我猜 find{} 不会返回对父子对象的真实引用?
【问题讨论】: