Class sap.ui.model.odata.v4.ODataContextBindingModule: sap/ui/model/odata/v4/ODataContextBinding


Context binding for an OData V4 model. An event handler can only be attached to this binding for the following events: 'change', 'dataReceived', and 'dataRequested'. For other events, an error is thrown.

A context binding can also be used as an operation binding to support bound actions, action imports and function imports. If you want to control the execution time of an operation, for example a function import named "GetNumberOfAvailableItems", create a context binding for the path "/GetNumberOfAvailableItems(...)" (as specified here, including the three dots). Such an operation binding is deferred, meaning that it does not request automatically, but only when you call execute. refresh is always ignored for actions and action imports. For function imports, it is ignored if execute has not yet been called. Afterwards it results in another call of the function with the parameter values of the last execute.

The binding parameter for bound actions may be given in the binding path, for example /TEAMS(Team_Id='TEAM_01')/tea_busi.AcChangeManagerOfTeam(...). This can be used if the exact instance is known in advance. If you use a relative binding instead, the operation path is a concatenation of the parent context's canonical path and the deferred binding's path.

Example: You have a table with a list binding to /TEAMS. In each row you have a button to change the team's manager, with the relative binding tea_busi.AcChangeManagerOfTeam(...). Then the parent context for such a button refers to an instance of TEAMS, so its canonical path is /TEAMS(ID='TeamID') and the resulting path for the action is /TEAMS(ID='TeamID')/tea_busi.AcChangeManagerOfTeam.

This also works if the relative path of the deferred operation binding starts with a navigation property. Then this navigation property will be part of the operation's resource path, which is still valid.

A deferred operation binding is not allowed to have another deferred operation binding as parent.

Constructor Summary
new sap.ui.model.odata.v4.ODataContextBinding(oModel, sPath, oContext?, mParameters?)DO NOT CALL this private constructor for a new ODataContextBinding, but rather use bindContext instead!
Event Summary
change(oEvent)The 'change' event is fired when the binding is initialized or its parent context is changed.
dataReceived(oEvent)The 'dataReceived' event is fired after the back end data has been processed.
dataRequested(oEvent)The 'dataRequested' event is fired directly after data has been requested from a back end.
Method Summary
sap.ui.model.odata.v4.ODataContextBinding.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.odata.v4.ODataContextBinding with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.odata.v4.ODataContextBinding.getMetadata()Returns a metadata object for class sap.ui.model.odata.v4.ODataContextBinding.
execute(sGroupId?)Calls the OData operation that corresponds to this operation binding.
initialize()Initializes the OData context binding.
isInitial()Method not supported
refresh(sGroupId?)Refreshes the binding.
resume()Method not supported
setParameter(sParameterName, vValue)Sets a parameter for an operation call.
suspend()Method not supported
toString()Returns a string representation of this object including the binding path.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.odata.v4.ODataContextBinding(oModel, sPath, oContext?, mParameters?)
DO NOT CALL this private constructor for a new ODataContextBinding, but rather use bindContext instead!
Parameters:
{sap.ui.model.odata.v4.ODataModel}oModel The OData V4 model
{string}sPath The binding path in the model; must not end with a slash
{sap.ui.model.Context}oContext? The context which is required as base for a relative path
{object}mParameters? Map of binding parameters which can be OData query options as specified in "OData Version 4.0 Part 2: URL Conventions" or the binding-specific parameters "$$groupId" and "$$updateGroupId". Note: Binding parameters may only be provided for absolute binding paths as only those lead to a data service request. The following OData query options are allowed:
  • All "5.2 Custom Query Options" except for those with a name starting with "sap-"
  • The $expand, $filter, $orderby and $select "5.1 System Query Options"; OData V4 only allows $filter and $orderby inside resource paths that identify a collection. In our case here, this means you can only use them inside $expand.
All other query options lead to an error. Query options specified for the binding overwrite model query options.
{string}mParameters.$$groupId? The group ID to be used for read requests triggered by this binding; if not specified, the model's group ID is used, see sap.ui.model.odata.v4.ODataModel. Valid values are undefined, '$auto', '$direct' or application group IDs as specified in sap.ui.model.odata.v4.ODataModel#submitBatch.
{string}mParameters.$$updateGroupId? The group ID to be used for update requests triggered by this binding; if not specified, the model's update group ID is used, see sap.ui.model.odata.v4.ODataModel. For valid values, see parameter "$$groupId".
Exceptions:
{Error}
If disallowed binding parameters are provided
Event Detail
change(oEvent)
The 'change' event is fired when the binding is initialized or its parent context is changed. It is to be used by controls to get notified about changes to the bound context of this context binding. Registered event handlers are called with the change reason as parameter.
Parameters:
{sap.ui.base.Event}oEvent
{object}oEvent.getParameters
{sap.ui.model.ChangeReason}oEvent.getParameters.reason The reason for the 'change' event: Change when the binding is initialized, Refresh when the binding is refreshed, and Context when the parent context is changed
Since:
1.37.0
See:
sap.ui.base.Event
dataReceived(oEvent)
The 'dataReceived' event is fired after the back end data has been processed. It is to be used by applications for example to switch off a busy indicator or to process an error.

If back end requests are successful, the event has no parameters. The response data is available in the model. Note that controls bound to this data may not yet have been updated; it is thus not safe for registered event handlers to access data via control APIs.

If a back end request fails, the 'dataReceived' event provides an Error in the 'error' event parameter.

Parameters:
{sap.ui.base.Event}oEvent
{object}oEvent.getParameters
{Error}oEvent.getParameters.error? The error object if a back end request failed. If there are multiple failed back end requests, the error of the first one is provided.
Since:
1.37.0
See:
sap.ui.base.Event
dataRequested(oEvent)
The 'dataRequested' event is fired directly after data has been requested from a back end. It is to be used by applications for example to switch on a busy indicator. Registered event handlers are called without parameters.
Parameters:
{sap.ui.base.Event}oEvent
Since:
1.37.0
See:
sap.ui.base.Event
Method Detail
sap.ui.model.odata.v4.ODataContextBinding.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.odata.v4.ODataContextBinding with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.ContextBinding.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.ui.model.odata.v4.ODataContextBinding.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.odata.v4.ODataContextBinding.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
execute(sGroupId?): Promise
Calls the OData operation that corresponds to this operation binding.

Parameters for the operation must be set via setParameter beforehand.

The value of this binding is the result of the operation. To access a result of primitive type, bind a control to the path "value", for example <Text text="{value}"/>. If the result has a complex or entity type, you can bind properties as usual, for example <Text text="{street}"/>.

Parameters:
{string}sGroupId? The group ID to be used for the request; if not specified, the group ID for this binding is used, see sap.ui.model.odata.v4.ODataContextBinding. Valid values are undefined, '$auto', '$direct' or application group IDs as specified in sap.ui.model.odata.v4.ODataModel#submitBatch.
Since:
1.37.0
Exceptions:
{Error} If the binding is not a deferred operation binding (see sap.ui.model.odata.v4.ODataContextBinding), if the binding is not resolved, or if the given group ID is invalid.
Returns:
{Promise} A promise that is resolved without data when the operation call succeeded, or rejected with an instance of Error in case of failure.
initialize()
Initializes the OData context binding. Fires a 'change' event in case the binding has a resolved path.
Since:
1.37.0
See:
sap.ui.model.Binding#initialize
isInitial()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Binding#isInitial
refresh(sGroupId?)
Refreshes the binding. Prompts the model to retrieve data from the server using the given group ID and notifies the control that new data is available. Refresh is supported for absolute bindings.

Note: When calling refresh multiple times, the result of the request triggered by the last call determines the binding's data; it is independent of the order of calls to sap.ui.model.odata.v4.ODataModel#submitBatch with the given group ID.

Parameters:
{string}sGroupId? The group ID to be used for refresh; if not specified, the group ID for this binding is used, see sap.ui.model.odata.v4.ODataContextBinding. Valid values are undefined, '$auto', '$direct' or application group IDs as specified in sap.ui.model.odata.v4.ODataModel#submitBatch.
Since:
1.37.0
Exceptions:
{Error} If the given group ID is invalid or refresh on this binding is not supported.
See:
sap.ui.model.Binding#refresh
resume()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Binding#resume
setParameter(sParameterName, vValue): sap.ui.model.odata.v4.ODataContextBinding
Sets a parameter for an operation call.
Parameters:
{string}sParameterName The parameter name
{any}vValue The parameter value
Since:
1.37.0
Exceptions:
{Error} If the binding is not a deferred operation binding (see sap.ui.model.odata.v4.ODataContextBinding) or if the value is missing
Returns:
{sap.ui.model.odata.v4.ODataContextBinding}this to enable method chaining
suspend()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Binding#suspend
toString(): string
Returns a string representation of this object including the binding path. If the binding is relative, the parent path is also given, separated by a '|'.
Since:
1.37.0
Returns:
{string} A string description of this binding