I have been following the guide in Documentation regarding deep composition. And I find this is very useful idea.
Now, here’s the scenario:
I have Entity A, that has lists of Entity B.
Entity A has property of amount.
In Web UI Screen, I use form and datasource. All according to the documentation. But, I want to change that everytime user edit “amount” in Entity A, it’ll automatically add new Entity B in the list.
So here’s the code example:
EntityB b = metadata.create(EntityB.class);
b.setTheA(getItem()); //Which refers to the current datasource of EntityA
bDs.addItem(b); //bDs is nested Collection datasource of current EntityA
But everytime I saved the data, it always throws error of violates non-null restriction. So, how can I add the new item in the datasource?