grails - 如何通过Grails中的所有参数调用另一个 Controller (以相同的形式更新关联的表)

标签 grails

我正在使用域类Alojamiento及其生成的 Controller 和 View 。 下一个代码有效:

我已经以的形式包括了的另一种形式:

<g:render template="../caracteristicas/form" bean="${params.caracteristicasInstance}" />

现在, Controller 编辑操作具有:
def alojamientoInstance = Alojamiento.get(id)
def caracteristicasInstance = alojamientoInstance.caracteristicas
[caracteristicasInstance: caracteristicasInstance,

并向更新 Controller 的操作:
def caracteristicasInstance = Caracteristicas.get(id)
caracteristicasInstance.properties = params
caracteristicasInstance.save(flush: true)

就像我说的那样,上面的代码可以工作,但是不能防止错误,因此,我尝试使用CaracteristicasController的更新操作(我在遵循这种方法:http://stuff4j.blogspot.com.es/2011/04/calling-controller-method-from-another.html)。 下一个代码不起作用,但我认为它可以解释自己在尝试的内容:
CaracteristicasController caracteristicasController = new CaracteristicasController()
CaracteristicasController.properties = params
CaracteristicasController.params.doNotRedirect = 'true' // See: http://stuff4j.blogspot.com.es/2011/04/calling-controller-method-from-another.html
CaracteristicasController.update()

顺便说一句,Grails的错误是:“无法设置只读属性:properties”

更新1

我想我没有很好地解释。我在_form.gsp 3中嵌入了_form.gsp(为了简化我在问题1中说过)。因此,当我编辑_form.gsp时,其他的也必须更新。我想调用“子” Controller 的更新 Action 来更新表单,但不要移至它们。我想保持在“父” Controller 中,以便当所有内容更新时,将出现“父”的show.gsp。我现在可以更好地解释吗?

最佳答案

为什么不都需要参数的redirectchain

关于grails - 如何通过Grails中的所有参数调用另一个 Controller (以相同的形式更新关联的表),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16761976/

相关文章:

testing - grails - 功能测试不会运行,即使是在 Intellij 中?

grails - 来自 Grails 的关于 Grails 错误的电子邮件通知

grails i18n 错误自定义 : various inconsistencies

grails - 在grails/groovy中访问子项目应用程序属性

grails - 是否可以允许编辑 GSP(包括布局)作为 Grails 应用程序功能的一部分?

java - Grails 验证中的自定义字段名称

hibernate - HQL和hasMany属性

grails - 如何在grails中以传输模式运行elasticsearch

hibernate - 3个实体之间的域关联

grails - Grails:从 View 更改数据集