Page 1 of 1

Save question before closing screen

PostPosted: Thu Aug 25, 2016 1:03 pm
by jvxdev
Is it possible to show a "Save changes" question before closing a screen?

If we use writeback isolation level DATAROW, it's a relevant question and also for simple Form screens, which only contains editors.

Re: Save question before closing screen

PostPosted: Thu Aug 25, 2016 1:12 pm
by Support@SIB
If you extend DataSourceWorkScreen, it should be possible to use:

Code: Select all
setAskBeforeClose(true);
//optional
//setAskBeforeCloseMessage("Save changes?");

Override the method

Code: Select all
protected boolean hasChanges()

if you need specific control about change detection.

If you don't extend the DataSourceWorkScreen, it's also possible but needs more work:

Overwrite the method

Code: Select all
notifyDestroy()

and check if your screen has changes. If it has changes, show a message and throw a SilentAbortException. The SilentAbortException won't open the error dialog but will cancel the current operation.

An example:

Code: Select all
if (isChanged())
{
    getApplication().showQuestion(this, "Save changes?",
                                  "doSaveChanges", "doRevertChanges");
   
    throw new SilentAbortException("Save question");
}