Editing composition entity programmatically do not reflect in its edit screen

We are using JMIX version 1.6. We have an entity ActivityGroup and within it composition entities Activity. In Edit screen of ActivityGroup, we are changing serial number of activities programmatically by pressing up & down buttons. But , they are not reflected in edit screen of Activity Entity. The changes are only reflected on using datamanager.save() or datacontext.commit() functions. What need to be done to access the edited Activity fields in edit screen of any other activity. The code being used is as follows:

Optional<TActivity> selActivity = getEditedEntity().getTactivities().stream().filter(act -> act.getSerialNumber().equals(selectedItemSN)).findFirst();
Optional<TActivity> preActivity = getEditedEntity().getTactivities().stream().filter(act -> act.getSerialNumber().equals(selectedItemSN - 1)).findFirst();
selActivity.get().setSerialNumber(selectedItemSN - 1);
preActivity.get().setSerialNumber(selectedItemSN);
tactivitiesTable.sort("serialNumber", Table.SortDirection.ASCENDING);

Please guide.

Hi, can any community member can guide on this issue? Thanks

Hi!

It’s not entirely clear what the problem is. Could you clarify how the screens open? In a new tab or in a dialog?

Could you please provide a small test project that reproduces the problem? This will speed up the solution to the problem.

Best regards,
Dmitriy

Thanks Dmitriy. A few of the issues are cleared while preparing the test project. The remaining issue we are facing that when we edit one of the composition entity and without saving parent entity we edit another composition entity we are unable to access the details of last edited composition entity. To make the issue clear, we have created a test project and the issue is marked as TODO in code. Please guide.
untitled.zip (2.0 MB)

Hi, can any community member can guide on this issue? Thanks

Hi,
I’m not sure if I faced the same problem. I also had a composition with a datagrid in the detailView of the main entity. After I tried to create a new object there, it also appeared in the dataGrid. If I then wanted to edit it, a window opened which displayed the details of the entity, but jmix wanted to create a new entity with these details. So I always had an SQL error because of the unique PK.

I was able to work around this by adding
entityStates.setNew(myNewEntity, false);
in the afterCloseListener of the create action.

Thanks Stefanie. But i have changed to structure of entire application changing all the composition entities with entities with association to parent entity which is mandatory. Please treat the issue closed.
Thanks.