The OData V4 model supports certain events intended for applications, and others that are to be used for controls, as outlined in this section.
For applications, the OData V4 model supports the following events:
-
The
dataRequestedanddataReceivedevents are typically used by applications to display and hide a busy indicator or to process a back-end error which happened when requesting data. The events are fired byODataPropertyBinding,ODataContextBindingandODataListBindingand bubbled up to the model when reading data:-
The
dataRequestedevent is fired directly after data has been requested from a back end. -
The
dataReceivedevent is fired after the back-end data has been processed. Note that thedataReceivedevent is also fired after a back-end request has failed. The error of the failed request is passed to the event handler as anerrorparameter. If multiple requests are processed within a single $batch (or even a single change set), the order ofdataReceivedevents is not guaranteed. For requests which are not processed because a previous request failed,error.causepoints to the root cause error - you should either ignore these events or unwrap the error to access the root cause immediately.
An event handler attached to the binding can prevent the event from bubbling up to the model by calling
oEvent.cancelBubble().The events are also fired, but only by the model, when additional properties are requested for an existing entity, for example after binding the row context of a list as a binding context for an object page (which typically displays many more properties). Note that this includes all requests for a context obtained via
ODataModel#getKeepAliveContext. Timing and parameters are exactly the same as described above. The application can use this event to be notified when data for the object page could not be requested.For more details, see the corresponding API documentation for
ODataModeland the specific bindings ODataPropertyBinding, ODataContextBinding and ODataListBinding in the Demo Kit. -
-
The
createSentandcreateCompletedevents at theODataListBindingare typically used by applications to lock the UI for the created entity to avoid modifications while the data for the created entity is sent to the back end, but the response from the back end is not yet processed on the client. For eachcreateSentevent, acreateCompletedevent is fired.-
The
createSentevent is fired each time a POST request that is initiated for anODataListBinding#createis sent to the backend. -
The
createCompletedevent is fired each time the back end has responded to a POST request initiated for anODataListBinding#create.
For more information, see
ODataListBinding#create. -
-
The
patchSentandpatchCompletedevents are typically used by applications that are using update groups with submit mode Auto (which is the default) and which need to be informed when PATCH requests are sent to the back end and when they are processed. For example, these events can be used to display aDraftIndicatorto inform the user that his changes are being saved and when saving is finished.The
patchSentandpatchCompletedevents are fired byODataContextBindingandODataListBindingif they send their own service request:-
The
patchSentevent is fired when the first PATCH request for this binding is sent to the backend. -
The
patchCompletedevent is fired when the backend has responded to the last PATCH request for this binding.
If
ODataContextBindingandODataListBindinguse the service request of a superordinate binding, the events are fired by the superordinate binding.For more details, see the corresponding API documentation for the specific bindings ODataContextBinding and ODataListBinding in the Demo Kit.
-
The events change and refresh are meant for controls only, and not available for app development. They indicate that the respective binding has new data which can be accessed by the control:
-
When the binding is initialized, it fires a
changeevent with the parameterreasonset tosap.ui.model.ChangeReason.Change. -
When a relative binding gets a new context, it fires a
changeevent with the parameterreasonset tosap.ui.model.ChangeReason.Context. -
When a binding is refreshed, the event fired depends on the binding type, as follows:
a)
ODataPropertyBindingandODataContextBindingfire achangeevent with the parameterreasonset tosap.ui.model.ChangeReason.Refresh.b)
ODataListBindingfires arefreshevent.
For more details, see the corresponding API documentation for the specific bindings ODataPropertyBinding, ODataContextBinding and ODataListBinding, as well as sap.ui.model.ChangeReason in the Demo Kit.
Related Information