openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

OData 2wayBinding and ODataPropertyBinding/ODataContextBinding dataReceived event

Open DerGuteWolf opened this issue 10 years ago • 13 comments

When a OData two-way binding update is processed in the backend, how is an error during the update available?

Unfortunately the documentation for the dataReceived event of ODataPropertyBinding/ODataContextBinding in rather unclear for this.

DerGuteWolf avatar Sep 30 '16 09:09 DerGuteWolf

@DerGuteWolf I am not sure what is unclear can you give more details? https://openui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.Binding.html#event:dataReceived

aborjinik avatar Oct 10 '16 13:10 aborjinik

the links talks only about data "received from a backend". I am talking about "sending data to a backend" which is not mentioned at all.

DerGuteWolf avatar Oct 10 '16 14:10 DerGuteWolf

When you are using TwoWay binding in the ODataModel and you submit your changes, the response will be checked for errors by the ODataMessageParser. If any errors occured, it will create Messages for these errors and make them available through the MessageManager.

https://help.sap.com/saphelp_nw75/helpdata/en/b8/c4e534cdb440e9a5bbff86f9572bd6/content.htm

If messages are related to a specific model property/binding they are shown at the corresponding edit control. Despite of that messages can be visualized by using the sap.m.MessageStrip oder sap.m.MessagePopover controls.

http://pipetree.com/qmacro/blog/2015/07/lightweight-notifications-with-the-message-strip/

goligo avatar Oct 11 '16 07:10 goligo

This all I know but is not relevant here (and does not work correctly in all circumstances, eg. when for the same entity a read is added automatically to the $batch by SAPUI5 the error from the change is lost for these displays, cf. https://github.com/SAP/openui5/issues/612).

I was just asking, how an error during a change from two-way binding is available in an event. @sirion thought in a private email correspondence related to he mentioned issue that the error might be delivered also to the dataReceived event. So this should at least be clarified if errors from two-way come up at dataReceived of the binding.

DerGuteWolf avatar Oct 11 '16 07:10 DerGuteWolf

Messages are propagated to bindings (only PropertyBindings so far) via a DataState object:

https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.DataState.html

You could attach to the AggregatedDataStateChange event of a PropertyBinding to listen for message changes:

https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.Binding.html#attachAggregatedDataStateChange

loginger avatar Oct 21 '16 08:10 loginger

Unfortunately "AggregatedDataStateChange" is not documented in sap.ui.model.Binding (and it should really be "aggregatedDataStateChange", since events in OpenUI5 normally start with lower case. And I don't see where a server-origin error message resulting from the change of a two-way binding would appear in sap.ui.model.DataState....

DerGuteWolf avatar Oct 23 '16 17:10 DerGuteWolf

I've created a internal incident 1770165555. You can check its status on GitHub.

Shtilianova avatar Apr 12 '17 11:04 Shtilianova

the documentation is simply wrong. It is 'aggregatedDataStateChange'. I'll fix that. I missed that the attach/detach is protected, so these are no option for you. As the submit isn't done via the ODataContextBinding the dataReceived event will not help you. If you submit the changes via submitChanges you could pass a success handler and check the responses for errors. This will work only in batch mode as in 'non' batch mode the handler will not be called. You also could attach to requestFailed/batchRequestCompleted event on the model to check for errors. This are all options we have so far...

loginger avatar Apr 12 '17 15:04 loginger

OK, so we need an option for this IMHO. Treat this as an enhancement request (besides the needed documentation additions/clarifications) if you like.

DerGuteWolf avatar Apr 12 '17 15:04 DerGuteWolf

And whether aggregatedDataStateChange or AggregatedDataStateChange, neither is documented....

DerGuteWolf avatar Apr 12 '17 15:04 DerGuteWolf

Unfortunatly the git commit only deals with the aggregatedDataStateChange documentation. I still don't see a solution how to get errore during a change from two-way binding in an event.

Besides there is a typo in the commit: sap.ui.model.DatatState

DerGuteWolf avatar Aug 16 '17 16:08 DerGuteWolf

We have no plans to enhance the implementation so far. You have to go with the events already provided by the Model...

loginger avatar Aug 17 '17 10:08 loginger

OK, should I create a new issue for an enhancement request then?

DerGuteWolf avatar Aug 17 '17 10:08 DerGuteWolf