Package io.jmix.flowui.model
Class DataContext.PreSaveEvent
java.lang.Object
java.util.EventObject
io.jmix.flowui.model.DataContext.PreSaveEvent
- All Implemented Interfaces:
Serializable
- Enclosing interface:
- DataContext
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(); } }
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionPreSaveEvent
(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 ifpreventSave()
method was called and save will be aborted.void
Invoke this method if you want to abort the saving process.Methods inherited from class java.util.EventObject
toString
-
Constructor Details
-
PreSaveEvent
-
-
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. -
preventSave
public void preventSave()Invoke this method if you want to abort the saving process. -
isSavePrevented
public boolean isSavePrevented()Returns true ifpreventSave()
method was called and save will be aborted.
-