嵌套内联域类编辑(Nested Inline Domain Class Edit)

编程入门 行业动态 更新时间:2024-10-28 20:26:29
嵌套内联域类编辑(Nested Inline Domain Class Edit)

我有一个名为UserForm的域类,其中有一个名为securityVerifications的List对象

class UserForm { List securityVerifications = new ArrayList() static hasMany = [ securityVerifications : SecurityVerification ] }

但是,域类SecurityVerification还有一个名为questions的List对象

我要做的是为用户构建一个表单来编辑这些List对象。

我可以让SecurityVerification的实例在没有问题的情况下保存,但是我无法获得要保存的Question实例。

我的UserController目前只是使用添加逻辑生成log.debug User保存的任何验证或错误。

我的观点相当复杂,但基本上输入字段具有以下内容,其中i是SecurityVerification索引, j是Question索引

name="securityVerifications[${i}].questions[${j}].<field>"

如何将嵌套的List对象保存在单个视图和控制器中?

I have a domain-class called UserForm with a List object called securityVerifications

class UserForm { List securityVerifications = new ArrayList() static hasMany = [ securityVerifications : SecurityVerification ] }

How ever, the domain-class SecurityVerification also has a List object called questions

What I'm trying to do is build a single form for the user to edit these List objects.

I can get the instances of SecurityVerification to save with out issue, but I can't get the instances of Question to save.

My UserController at the moment is simply generated with addition logic to log.debug any validation or errors for User saving.

And my view is fairly complex, but essentially input fields have the following with i being index of SecurityVerification and j being Question index

name="securityVerifications[${i}].questions[${j}].<field>"

How can I get nested List objects to save in a single view and controller?

最满意答案

解决了我的问题。 基本上,域级Question具有外键关系属性。

class Question { SomeClass someClass }

将输入字段和选项传递回UserFormController无法将String id与类相关联。 抛出类型错误。

通过解决这个问题,我使用了Long的原始数据类型

class Question { Long someClassId }

当谈到显示或后保存编辑时,我只是做了:

SomeClass.get(question.someclassID)

Solved the my issue. Basically the domain-class Question had a foreign key relationship property.

class Question { SomeClass someClass }

The method of which passing the input fields and options back to the UserFormController could not relate the String id to the class. Throwing a type error.

By solving this issue, I used a primitive datatype of Long

class Question { Long someClassId }

When it came to the Show or post-save edit, I simply just did:

SomeClass.get(question.someclassID)

更多推荐

本文发布于:2023-07-27 08:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1287987.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内联   嵌套   编辑   Nested   Edit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!