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.
ODataContextBinding
, but rather use bindContext instead!sClassName
and enriches it with the information contained in oClassInfo
.ODataContextBinding
, but rather use bindContext instead! {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:
|
{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
{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
sap.ui.base.Event |
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.
{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
sap.ui.base.Event |
{sap.ui.base.Event} | oEvent |
- Since:
- 1.37.0
sap.ui.base.Event |
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.
{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 |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
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}"/>
.
{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
{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. |
{Promise} | A promise that is resolved without data when the operation call succeeded, or rejected with an instance of Error in case of failure. |
- Since:
- 1.37.0
sap.ui.model.Binding#initialize |
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.
{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
{Error} | If the given group ID is invalid or refresh on this binding is not supported. |
sap.ui.model.Binding#refresh |
{string} | sParameterName | The parameter name |
{any} | vValue | The parameter value |
- Since:
- 1.37.0
{Error} | If the binding is not a deferred operation binding (see sap.ui.model.odata.v4.ODataContextBinding) or if the value is missing |
{sap.ui.model.odata.v4.ODataContextBinding} | this to enable method chaining |