Class DataContext.PreSaveEvent

java.lang.Object
java.util.EventObject
io.jmix.flowui.model.DataContext.PreSaveEvent
All Implemented Interfaces:
Serializable
Enclosing interface:
DataContext

public static class DataContext.PreSaveEvent extends EventObject
Event sent before saving changes.

In this event listener, you can add arbitrary entity instances to the saved collections returned by getModifiedInstances() and getRemovedInstances() methods, for example:

     @Subscribe(target = Target.DATA_CONTEXT)
     protected void onPreSave(DataContext.PreSaveEvent event) {
         event.getModifiedInstances().add(customer);
     }
 

You can also prevent saving using the preventSave() method of the event, for example:

     @Subscribe(target = Target.DATA_CONTEXT)
     protected void onPreSave(DataContext.PreSaveEvent event) {
         if (doNotSave()) {
             event.preventSave();
         }
     }
 
See Also:
  • Constructor Details

  • Method Details

    • getSource

      public DataContext getSource()
      The data context which sent the event.
      Overrides:
      getSource in class EventObject
    • getModifiedInstances

      public Collection getModifiedInstances()
      Returns the collection of modified instances.
    • getRemovedInstances

      public Collection getRemovedInstances()
      Returns the collection of removed instances.
    • preventSave

      public void preventSave()
      Invoke this method if you want to abort the saving process.
    • isSavePrevented

      public boolean isSavePrevented()
      Returns true if preventSave() method was called and save will be aborted.