Openui5: v2.ODataModel (1.26.6) submitChanges callbacks without BatchMode [Feature Request]

Created on 7 Feb 2015  路  14Comments  路  Source: SAP/openui5

Currently the documentation says:

Important: The success/error handler will only be called if batch support is enabled!

Our PHP OData layer currently does not support batch requests. Our HANA SP85 does not support batch(MERGE) (hopefully SP90 will do) so i am not able to use the batchMode.

My CRUD controller will do a controlled SubmitChanges on Form Button SAVE click.

Currently i am not easily able to have a fnCallback for success/error on this!!!

I think we need a promise like callback collector that will do the job if all updates are fullfilled.
From my opinion the work for doing this leads to the currently missing implementation, or what is the reason?

Is this support on your roadmap?

Cheers Holger

consulting

Most helpful comment

After reading the explenation and posts here I have to say I don't really see a need for callbacks from submitChanges. The documentation on the other hand would benifit greatly from some explanation of the rationale behind the decision.

Anyway for anyone else comming here looking for a solution, hooking up the delegates on the individual methods work:

oModel.createEntry("/OrderSet", { success: function(oData, oResponse) {
    alert("Success!");
}, error: function(error) {
    alert("Error!");    
}});
oModel.submitChanges();

All 14 comments

Hi Holger,
I asked the responsible developer to have a look.

Cheers
Andreas

Hi Holger,

while the success/error handler of the submitChanges method are not called, if multiple CRUD requests are contained, the individual success/error handlers of each contained read/update/remove method will be called when submitChanges is executed. Isn't that sufficient for your need?

Regards,
Malte

Hi Goligo,
i will try if i can use hasDependingChanges also with oModel.update()

                 if (_bHasPendingChanges) {
                    oModel.submitChanges({ // does not work 
                        success : function(oData) { // does not work without batch
                            console.log("submitChangesSuccess", oData);
                        },
                        error : function(oError) { // does not work without batch
                            console.log("submitChangesError", oError);
                        }
                        //eTag : ""
                    });
                    console.log("saveModel", oModel);
                } else {
                    console.log("no pending changes...");
                }

I will try oModel.update(sPath, oData, mParameters?) instead.

Will have a look if i can get the changed/binded (oData) data easily from v2Model

  • sPath (easy like "/UmeUser(1)")
  • oData (needs to know how to get oModel.getData/getObject for current path

Will see if this will work for me.
I will not manually collect all data from Input fields.

Cheers Holger

Hi Holger,

did it work?

If yes, please let us know so that we can close this issue.
If not, please follow up with us to further analyze it.

Cheers,
Michael

Hi Michael,
i just tried it out and get to know, that i did not understand the hint from Malte.

My current approach is also to use
this.getView().getModel().createEntry(sCreatePath, {});

to create a new entry like
UmeUsers('id-1426694995628-2')

It would be cool to use oModel.submitChanges() in this case (CREATE/ADD) also.

A manually update via
oBindingContext.getModel().update()
catches the correct error/success handler, but leads to some ugly side effects like errors on expanded navigation properties (because deep updates are not supported).

This works well inside .submitChanges().

So i had to manually things like
delete oEntry.UmeAccount;

How can i use oModel.submitChanges() with all the nice benefits but without batching.
How can i attach the the individual success/error handlers of each contained read/update/remove as Malte explained.

Any help would be greatly appreciated ;-)

Cheers Holger

I would also love to use submitChanges() while having my success/error functions called without using batch (I'm using ASP.NET Web API OData v1-3 package which does not support this).

I'm sure internally, you'd need to aggregate each request that is sent and completed before calling success/error callbacks.

Is there a reasonable alternative to find which sPath entries within the ODataModel are marked as pending changed (rather than entire model) so that we could loop through each key and call create/update/delete manually?

HI,

Did anyone solve this issue or is there a known workaround for it?

Regards, Alex

A question to people watching this issue: How would you expect the success/error handler to be called, if batch is not enabled? Often there are multiple requests triggered when calling submitChanges. Would you expect it to be called separately for each request which is sent, or do you expect a single success/error callback? If you expect a single success/error callback, do you expect the error-callback only if all requests failed or if one of the contained requests failed?

have any solution to call the Success or Error handlers for submit changes.. Please let me know ASAP.

After reading the explenation and posts here I have to say I don't really see a need for callbacks from submitChanges. The documentation on the other hand would benifit greatly from some explanation of the rationale behind the decision.

Anyway for anyone else comming here looking for a solution, hooking up the delegates on the individual methods work:

oModel.createEntry("/OrderSet", { success: function(oData, oResponse) {
    alert("Success!");
}, error: function(error) {
    alert("Error!");    
}});
oModel.submitChanges();

Hi @hschaefer123 @ramu6984,
is the proposal by @t0PPy works for you?

ilhan

Looks good!
;-)

I was asked here to elaborate here for a callback, here we go:

  • odata 2.0
  • Two-Way-Binding
  • Batch=true
  1. user can change multiple values in multiple linked entities, all bound to the xml view (e.g. a survey form with multiple questions)
  2. There is a print button, which generates a pdf on the backend
  3. we must save all input before printing, to create a matching pdf
  4. app should set a busy indicator, while saving

Now we have this situation(user is pressing print):

  1. if there are changes, we can set busy before submit and it works as expected
  2. if there are no changes, nothing happens, view will stay busy.
  3. Because of a bug https://github.com/SAP/openui5/issues/1756, there is no way to determine if we have to call submitChanges(), without accessing private accessors.

So it would be great to have one callback, called every time; Independent of error, success as requested here( https://github.com/SAP/openui5/issues/1755)

@bkrr I meant to use the issue you opened as this one is closed. I will copy the details in https://github.com/SAP/openui5/issues/1755 and we can continue in it.

Was this page helpful?
0 / 5 - 0 ratings