Package io.jmix.flowui.view
Class StandardDetailView.BeforeSaveEvent
java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<View<?>>
io.jmix.flowui.view.StandardDetailView.BeforeSaveEvent
- All Implemented Interfaces:
- Serializable
- Enclosing class:
- StandardDetailView<T>
public static class StandardDetailView.BeforeSaveEvent
extends com.vaadin.flow.component.ComponentEvent<View<?>>
Event sent before saving the view data context.
 
Use this event listener to prevent saving and/or interact with the user before save, for example:
Use this event listener to prevent saving and/or interact with the user before save, for example:
     @Subscribe
     protected void onBeforeSave(BeforeSaveEvent event) {
         if (getEditedEntity().getDescription() == null) {
             notifications.show("Description required");
             event.preventSave();
         }
     }
 
 Show dialog and resume saving after:
     @Subscribe
     protected void onBeforeSave(BeforeSaveEvent event) {
         if (getEditedEntity().getDescription() == null) {
             dialogs.createOptionDialog()
                     .withHeader("Question")
                     .withText("Do you want to set default description?")
                     .withActions(
                             new DialogAction(DialogAction.Type.YES).withHandler(e -> {
                                 getEditedEntity().setDescription("No description");
                                 // retry save and resume action
                                 event.resume(save());
                             }),
                             new DialogAction(DialogAction.Type.NO).withHandler(e -> {
                                 // trigger standard save and resume action
                                 event.resume();
                             })
                     )
                     .open();
             event.preventSave();
         }
     }
 - 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final Runnableprotected booleanprotected OperationResultFields inherited from class java.util.EventObjectsource
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanvoidPrevents saving of the view data.voidpreventSave(OperationResult saveResult) Prevents saving of the view data.voidresume()Resume standard execution.voidresume(OperationResult result) Resume with the passed result ignoring standard execution.Methods inherited from class com.vaadin.flow.component.ComponentEventgetSource, isFromClient, unregisterListenerMethods inherited from class java.util.EventObjecttoString
- 
Field Details- 
resumeAction
- 
savePreventedprotected boolean savePrevented
- 
saveResult
 
- 
- 
Constructor Details- 
BeforeSaveEvent
 
- 
- 
Method Details- 
getDataContext- Returns:
- data context of the view
 
- 
preventSavepublic void preventSave()Prevents saving of the view data.
- 
preventSavePrevents saving of the view data.- Parameters:
- saveResult- result object that will be returned from the- StandardDetailView.saveChanges(boolean)} method
 
- 
resumepublic void resume()Resume standard execution.
- 
resumeResume with the passed result ignoring standard execution. The standard save will not be performed.
- 
getSaveResult- Returns:
- result passed to the preventSave(OperationResult)method
 
- 
isSavePreventedpublic boolean isSavePrevented()- Returns:
- whether the saving process was prevented by invoking preventSave()method
 
 
-