use of org.activityinfo.ui.client.component.form.event.BeforeSaveEvent in project activityinfo by bedatadriven.
the class FormActions method save.
public Promise<List<FormInstance>> save() {
model.getEventBus().fireEvent(new BeforeSaveEvent());
final List<FormInstance> instancesToPersist = getInstancesToPersist();
Promise<Void> persist = locator.persist(instancesToPersist);
Promise<Void> remove = remove();
final Promise<List<FormInstance>> result = new Promise<>();
Promise.waitAll(persist, remove).then(new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
result.onFailure(caught);
}
@Override
public void onSuccess(Void input) {
model.getChangedInstances().clear();
result.onSuccess(instancesToPersist);
}
});
return result;
}
Aggregations