When does the save dialog get triggered?

Hello,

I was wondering when the “Do you want to save your changes” dialog gets triggered. I have a screen on a tab and when I try to close the tab the dialog pops up. The dataContext had some modified instances due to a custom dataLoader but I used dataContext.evictModified() to remove everything that should trigger the dialog. This worked, there are no modified instances when I close the screen. The deletedInstances in the dataContext are also empty so I like to know what I can do to find out what CUBA thinks that needs to be saved.

Thank you in advance!

Hi,
If your screen is descendant of StandardEditor - then take a look at the method com.haulmont.cuba.gui.screen.StandardEditor#hasUnsavedChanges (most probably, modifiedAfterOpen flag is set).

Thank you for the information. So if any entity egts changed and is moved to modifiedInstances, the hasUnsavedChanged is set to true and stays true even when the instances are removed from modifiedInstances? Is there any way to reset the flag?
The problem is we sometime get entities moved to the modifiedInstances without a “real” change, for example we display a collection of that entity in a data grid and sort the items by date. We need to use getMutableItems for that and that triggers a merge and somehow detects that the items in the collection are different from the parent entity so the parent entity gets moved to modifiedInstances.
We would like to reset all information about changes in the afterShow event so only real user input will be detected as a change to the entity.

Call StandardEditor#setModifiedAfterOpen(false)
This method is protected, like many other methods in the StandardEditor class. This class is designed for extension and customisation.

Thank you Alexander, that works like a charm! :slight_smile: