Package io.jmix.flowui.model
Class DataContext.PreCommitEvent
java.lang.Object
java.util.EventObject
io.jmix.flowui.model.DataContext.PreCommitEvent
- All Implemented Interfaces:
Serializable
- Enclosing interface:
- DataContext
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(); } }
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionPreCommitEvent
(DataContext dataContext, Collection modified, Collection removed) -
Method Summary
Modifier and TypeMethodDescriptionReturns the collection of modified instances.Returns the collection of removed instances.The data context which sent the event.boolean
Returns true ifpreventCommit()
method was called and commit will be aborted.void
Invoke this method if you want to abort the commit.Methods inherited from class java.util.EventObject
toString
-
Constructor Details
-
PreCommitEvent
-
-
Method Details
-
getSource
The data context which sent the event.- Overrides:
getSource
in classEventObject
-
getModifiedInstances
Returns the collection of modified instances. -
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 ifpreventCommit()
method was called and commit will be aborted.
-