Search in sources :

Example 1 with CloseEvent

use of com.sencha.gxt.widget.core.client.event.CloseEvent in project activityinfo by bedatadriven.

the class FormInputView method save.

public void save(CloseEvent.CloseHandler closeHandler) {
    // If the view model is still loading, ignore this click
    if (viewModel == null) {
        return;
    }
    if (!viewModel.isValid()) {
        MessageBox box = new MessageBox(I18N.CONSTANTS.error(), I18N.CONSTANTS.pleaseFillInAllRequiredFields());
        box.setModal(true);
        box.show();
        return;
    }
    // Good to go...
    RecordTransaction tx = viewModel.buildTransaction();
    LOGGER.info("Submitting transaction: " + Json.stringify(tx));
    formStore.updateRecords(tx).then(new AsyncCallback<Void>() {

        @Override
        public void onFailure(Throwable caught) {
            MessageBox box = new MessageBox(I18N.CONSTANTS.serverError(), I18N.CONSTANTS.errorOnServer());
            box.setModal(true);
            box.show();
        }

        @Override
        public void onSuccess(Void result) {
            closeHandler.onClose(new CloseEvent(null));
        }
    });
}
Also used : CloseEvent(com.sencha.gxt.widget.core.client.event.CloseEvent) MessageBox(com.sencha.gxt.widget.core.client.box.MessageBox) RecordTransaction(org.activityinfo.model.resource.RecordTransaction)

Aggregations

MessageBox (com.sencha.gxt.widget.core.client.box.MessageBox)1 CloseEvent (com.sencha.gxt.widget.core.client.event.CloseEvent)1 RecordTransaction (org.activityinfo.model.resource.RecordTransaction)1