Class DataContext.PreCommitEvent

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

public static class DataContext.PreCommitEvent extends EventObject
Event sent before committing changes.

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

     @Subscribe(target = Target.DATA_CONTEXT)
     protected void onPreCommit(DataContext.PreCommitEvent event) {
         event.getModifiedInstances().add(customer);
     }
 
You can also prevent commit using the preventCommit() method of the event, for example:
     @Subscribe(target = Target.DATA_CONTEXT)
     protected void onPreCommit(DataContext.PreCommitEvent event) {
         if (doNotCommit()) {
             event.preventCommit();
         }
     }
 
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.
    • preventCommit

      public void preventCommit()
      Invoke this method if you want to abort the commit.
    • isCommitPrevented

      public boolean isCommitPrevented()
      Returns true if preventCommit() method was called and commit will be aborted.