public static class MasterDetailScreen.BeforeCommitChangesEvent
extends java.util.EventObject
MasterDetailScreen.commitEditorChanges()
call.
@Subscribe protected void onBeforeCommit(BeforeCommitChangesEvent event) { if (getEditedEntity().getDescription() == null) { notifications.create().withCaption("Description required").show(); event.preventCommit(); } }Show dialog and resume commit after:
@Subscribe protected void onBeforeCommit(BeforeCommitChangesEvent event) { if (getEditedEntity().getDescription() == null) { dialogs.createOptionDialog() .withCaption("Question") .withMessage("Do you want to set default description?") .withActions( new DialogAction(DialogAction.Type.YES).withHandler(e -> { getEditedEntity().setDescription("No description"); // retry commit and resume action event.resume(commitEditorChanges()); }), new DialogAction(DialogAction.Type.NO).withHandler(e -> { // trigger standard commit and resume action event.resume(); }) ) .show(); event.preventCommit(); } }
Modifier and Type | Field and Description |
---|---|
protected boolean |
commitPrevented |
protected OperationResult |
commitResult |
protected java.lang.Runnable |
resumeAction |
Constructor and Description |
---|
BeforeCommitChangesEvent(Screen source,
java.lang.Runnable resumeAction) |
Modifier and Type | Method and Description |
---|---|
OperationResult |
getCommitResult() |
DataContext |
getDataContext() |
Screen |
getSource() |
boolean |
isCommitPrevented() |
void |
preventCommit()
Prevents commit of the editor form.
|
void |
preventCommit(OperationResult commitResult)
Prevents commit of the editor form.
|
void |
resume()
Resume standard execution.
|
void |
resume(OperationResult result)
Resume with the passed result ignoring standard execution.
|
protected final java.lang.Runnable resumeAction
protected boolean commitPrevented
protected OperationResult commitResult
public BeforeCommitChangesEvent(Screen source, java.lang.Runnable resumeAction)
public Screen getSource()
getSource
in class java.util.EventObject
public DataContext getDataContext()
public void preventCommit()
public void preventCommit(OperationResult commitResult)
commitResult
- result object that will be used to resume entity savingpublic void resume()
public void resume(OperationResult result)
@Nullable public OperationResult getCommitResult()
preventCommit(OperationResult)
methodpublic boolean isCommitPrevented()
preventCommit()
method