Object inside another Object?

Jamie Sammons, modified 2 Years ago. New Member Posts: 6 Join Date: 3/9/23 Recent Posts

Hello everyone, i'm trying to understand how could i develop an object that stores other objects.
To understand better, I use a form to get some data from the user and after I store these datas in an object and I display all datas in another page.

Now i would like to give to users the possibility to leave a comment and I was thinking to store the comments like a new object inside the original one. Is it possible?

Thanks everyone.

thumbnail
Jamie Sammons, modified 2 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

Well, not an object inside of an object, but you can define relationships to objects and then leverage the relationship to have a similar concept of one object containing another.

Unfortunately at this time Liferay only supports a one to many or many to many relationship between objects, although we have been pushing the team to introduce a one to one relationship. A one to many can simulate this if you add actions to prevent adding multiple children in the one to many relationship, but I (and others) feel this is a bit hacky. So one to one is on the roadmap, we're just not sure when it will be delivered.

Jamie Sammons, modified 2 Years ago. New Member Posts: 6 Join Date: 3/9/23 Recent Posts

Thanks everyone for the reply.

thumbnail
Jamie Sammons, modified 2 Years ago. New Member Posts: 3 Join Date: 10/9/20 Recent Posts

Hello,

You can not add one object to another object, but you can do mapping between the objects

You just need to create one-to-many type mapping from the main object to the comment object

Once you do the mapping, you can add one more tab to the VIEW section and add a view of the relations

Let me know if you want step to step guide for this

Jamie Sammons, modified 2 Years ago. New Member Posts: 6 Join Date: 3/9/23 Recent Posts

Thanks, I think i set it up well but a step to step guide would be very appreciated, last thing, after I have the relationship how can i display it in a new page? Because I was trying to display it with a form + display content but when I try to map a Form Field to the relationship it doesn't work because it can't find the relationship but it find only normal fields.

Thanks.