OData 2wayBinding and ODataPropertyBinding/ODataContextBinding dataReceived event
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 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
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.
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/
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.
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
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....
I've created a internal incident 1770165555. You can check its status on GitHub.
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...
OK, so we need an option for this IMHO. Treat this as an enhancement request (besides the needed documentation additions/clarifications) if you like.
And whether aggregatedDataStateChange or AggregatedDataStateChange, neither is documented....
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
We have no plans to enhance the implementation so far. You have to go with the events already provided by the Model...
OK, should I create a new issue for an enhancement request then?