I have two entities, Master and Detail, with a composition relationship. I want to be able to select multiple Masters, open a screen that lets me enter then information for a new Detail, and then associate one copy of this Detail to each of the selected Masters. Is there a way to do this? The most I seem to be able to find for this is the Bulk Editor option, but this, from my understanding, doesn’t let me edit the associated Details.
Do you need a one-to-one or one-to-many composition of details?
It is a one-to-many relationship. The Master entity is really a manufacturing part and the Detail is a shipping record. Some of our parts are shipped and received multiple times so I need to keep all of the shipping records so we can go back and look through its full life cycle. I’m trying to simplify the shipping process by letting them ship out multiple parts to the same person and only have to input the shipping info once.
This case is quite exotic but still realizable.
We’ve made this case work in a sample project: https://github.com/cuba-labs/multiple-details-addition
The logic of details addition is implemented in the MasterBrowse.java controller: when you click the Add details button, the details editor is opened in a dialog window, and the input value is added to all Master instances selected in the table.
You can also try to implement the logic in the Master editor, passing the set of selected Master instances as a screen parameter, but it will demand to reload the instances with a full view (you don’t load all the details in Master browser, do you?) and a fine tuning of commit process.