Get key of parent row

I will try to explain what I need :smile:

I have Customer and Order enties, like in the tutorial.
When I open the Customer edit mask I see all related Orders.
Now I do a right click in the Order list and select ‘create’.
The Order edit mask pops up.
Now I could select the Customer for which I want to create a new order.
But, I would like to get this preselected based on the Customer I am coming from.

Any tip would be great.

Thx.

hi,

this behavior is the default behavior in a composition relationship. But it requires that the view of the order contains the minimal view of the customer attribute.

Can you share your views.xml as well as your Customer.java & Order.java? Then we can double check…

Here’s an example I once gave where you can see the default behavior: https://youtu.be/2798x5CKfxs?t=1639

Bye
Mario

2 Likes

Hi Mario,

thx!
Very helpful video.
Will try that out.
Because I have DB models only designed by the DB team I will see,
if this fits well into the needs of the composition way…
Will inform you on Monday.

Roland

hi,

you can check out this project here (which is more or less the content of the video):

Here you can see the customer editor screen & order editor screen in action:

customer-editor

order-editor

Bye
Mario

Setting the entity association to “composition“ does not change neccessary the way the tables are setup. It depends on how you already structured your entities.

That said, imho you’ll have a hard time letting the datamodel be defined outside of your control. When working with ORMs and especially with these full stack frameworks like CUBA is, they are making certain assumptions or have conventions that best practices but not neccessary exactly what your ‘db apartment’ would do.

The reason is that the entities and how they are layed out is the center of CUBA. A lot of stuff is built on top of that. One example is how the screen generation and default behavior of screens works.

So if you give that out of the developers control and the db model is not setup as cubas default, you will miss a lot of convinience that you would otherwise have. Im not saying it is not possile, cuba can handle different db schema settings, but it is far from optimal imho.

Bye
Mario

1 Like

Hi,

I have to go the ‘hard’ way.
No chance to let Cuba create the DB model.

Roland