Model implementation for OData V4.
This model is not prepared to be inherited from.
Every resource path (relative to the service root URL, no query options) according to "4 Resource Path" in specification "OData Version 4.0 Part 2: URL Conventions" is a valid data binding path within this model if a leading slash is added; for example "/" + "SalesOrderList('A%2FB%26C')" to access an entity instance with key "A/B&C". Note that appropriate URI encoding is necessary, see the example of sap.ui.model.odata.v4.ODataUtils.formatLiteral. "4.5.1 Addressing Actions" needs an operation binding, see sap.ui.model.odata.v4.ODataContextBinding.
Note that the OData V4 model has its own sap.ui.model.odata.v4.Context class. Bindings which are relative to such a V4 context depend on their corresponding parent binding and do not access data with their own service requests unless parameters are provided.
Group IDs control the model's use of batch requests. Valid group IDs are:
mParameters.groupProperties
. Constructor for a new ODataModel.
new sap.ui.model.odata.v4.ODataModel(mParameters)
Param | Type | Default Value | Description |
---|---|---|---|
mParameters | object | The parameters |
|
annotationURI? | string string[] | The URL (or an array of URLs) from which the annotation metadata are loaded. The annotation files are merged into the service metadata in the given order (last one wins). The same annotations are overwritten; if an annotation file contains other elements (like a type definition) that are already merged, an error is thrown. Supported since 1.41.0 |
|
autoExpandSelect? | boolean | Whether the OData model's bindings automatically generate $select and $expand system query options from the binding hierarchy. Note: Dynamic changes to the binding hierarchy are not supported. This parameter is supported since 1.47.0, and since 1.75.0 it also enables property paths containing navigation properties in |
|
earlyRequests? | boolean | Whether the following is requested at the earliest convenience:
true in later releases. You may also set Manifest Model Preload in order to further speed up the start of a UI5 component. |
|
groupId? | string | "$auto" | Controls the model's use of batch requests: '$auto' bundles requests from the model in a batch request which is sent automatically before rendering; '$direct' sends requests directly without batch; other values result in an error |
groupProperties? | object | Controls the use of batch requests for application groups. A map of application group IDs having an object with exactly one property |
|
httpHeaders? | object | Map of HTTP header names to their values, see #changeHttpHeaders |
|
metadataUrlParams? | object | Additional map of URL parameters used specifically for $metadata requests. Note that "sap-context-token" applies only to the service's root $metadata, but not to "cross-service references". Supported since 1.81.0 |
|
odataVersion? | string | "4.0" | The version of the OData service. Supported values are "2.0" and "4.0". |
operationMode? | sap.ui.model.odata.OperationMode | The operation mode for filtering and sorting. Since 1.39.0, the operation mode sap.ui.model.odata.OperationMode.Server is supported. All other operation modes including |
|
serviceUrl | string | Root URL of the service to request data from. The path part of the URL must end with a forward slash according to OData V4 specification ABNF, rule "serviceRoot". You may append OData custom query options to the service root URL separated with a "?", for example "/MyService/?custom=foo". See specification "OData Version 4.0 Part 2: URL Conventions", "5.2 Custom Query Options". OData system query options and OData parameter aliases lead to an error. |
|
sharedRequests? | boolean | Whether all list bindings for the same resource path share their data, so that it is requested only once; only the value |
|
supportReferences? | boolean | true | Whether |
synchronizationMode | string | Controls synchronization between different bindings which refer to the same data for the case data changes in one binding. Must be set to 'None' which means bindings are not synchronized at all; all other values are not supported and lead to an error. |
|
updateGroupId? | string | The group ID that is used for update requests. If no update group ID is specified, |
Event | Description |
---|---|
parseError |
The 'parseError' event is not supported by this model. |
propertyChange |
The 'propertyChange' event is not supported by this model. |
requestCompleted |
The 'requestCompleted' event is not supported by this model. |
requestFailed |
The 'requestFailed' event is not supported by this model. |
requestSent |
The 'requestSent' event is not supported by this model. |
sessionTimeout |
The 'sessionTimeout' event is fired when the server has created a session for the model and this session ran into a timeout due to inactivity. |
Method | Description |
---|---|
attachEvent |
See sap.ui.base.EventProvider#attachEvent
|
attachSessionTimeout |
Attach event handler |
bindContext |
Creates a new context binding for the given path, context and parameters.
|
bindList |
Creates a new list binding for the given path and optional context which must resolve to an absolute OData path for an entity set.
|
bindProperty |
Creates a new property binding for the given path. This binding is inactive and will not know the property value initially. You have to call sap.ui.model.Binding#initialize to get it updated asynchronously and register a change listener at the binding to be informed when the value is available. It is possible to create a property binding pointing to metadata. A '##' in the binding's path is recognized as a separator and splits it into two parts. The part before the separator is resolved with the binding's context and the result is transformed into a metadata context (see sap.ui.model.odata.v4.ODataMetaModel#getMetaContext). The part following the separator is then interpreted relative to this metadata context, even if it starts with a '/'; see sap.ui.model.odata.v4.ODataMetaModel#requestObject for more details. If the target type specified in the corresponding control property's binding info is "any" and the binding is relative or points to metadata, the binding may have an object value; in this case and unless the binding refers to an action advertisement the binding's mode must be sap.ui.model.BindingMode.OneTime.
|
bindTree |
Method not supported
|
changeHttpHeaders |
Changes the HTTP headers used for data and metadata requests sent by this model. If batch requests are used, the headers will be set for the batch itself, as well as for the individual requests within the batch. The headers are changed according to the given map of headers: Headers with an
If not
References:
|
createBindingContext |
Creates a binding context for the given path. A relative path can only be resolved if a context is provided. Note: The parameters It is possible to create binding contexts pointing to metadata. A '##' is recognized as separator in the resolved path and splits it into two parts; note that '#' may also be used as separator but is deprecated since 1.51. The part before the separator is transformed into a metadata context (see sap.ui.model.odata.v4.ODataMetaModel#getMetaContext). The part following the separator is then interpreted relative to this metadata context, even if it starts with a '/'; a trailing '/' is allowed here, see sap.ui.model.odata.v4.ODataMetaModel#requestObject for the effect it has. A binding path may also point to an operation advertisement which is addressed with '# Examples:
References:
|
destroy |
Destroys this model, its requestor and its meta model.
|
destroyBindingContext |
Method not supported |
detachSessionTimeout |
Detach event handler |
sap.ui.model.odata.v4.ODataModel.extend |
Creates a new subclass of class sap.ui.model.odata.v4.ODataModel with name
|
getAllBindings |
Returns the model's bindings. |
getGroupId |
Returns the model's group ID.
|
getHttpHeaders |
Returns a map of HTTP headers used for data and metadata requests. While the "X-CSRF-Token" header is not used for metadata requests, it is still included here if available. The "SAP-ContextId" header is only included if requested explicitly (@since 1.86.0).
|
getMessages |
Returns messages of this model associated with the given context, that is messages belonging to the object referred to by this context or a child object of that object. The messages are sorted by their type according to the type's severity in a way that messages with highest severity come first.
|
sap.ui.model.odata.v4.ODataModel.getMetadata |
Returns a metadata object for class sap.ui.model.odata.v4.ODataModel. |
getMetaModel |
Returns the meta model for this ODataModel. |
getObject |
Method not supported |
getODataVersion |
Returns the version of the OData service. |
getOriginalProperty |
Method not supported |
getProperty |
Method not supported
|
getUpdateGroupId |
Returns the model's update group ID.
|
hasPendingChanges |
Returns |
refresh |
Refreshes the model by calling refresh on all bindings which have a change event handler attached. Note: When calling #refresh multiple times, the result of the request triggered by the last call determines the model's data; it is independent of the order of calls to #submitBatch with the given group ID. If there are pending changes, an error is thrown. Use #hasPendingChanges to check if there are pending changes. If there are changes, call #submitBatch to submit the changes or #resetChanges to reset the changes before calling #refresh.
|
requestCanonicalPath |
Returns a promise for the "canonical path" of the entity for the given context. According to "4.3.1 Canonical URL" of the specification "OData Version 4.0 Part 2: URL Conventions", this is the "name of the entity set associated with the entity followed by the key predicate identifying the entity within the collection". Use the canonical path in sap.ui.core.Element#bindElement to create an element binding.
Since 1.39.0 Use {@link sap.ui.model.odata.v4.Context#requestCanonicalPath} instead.
|
resetChanges |
Resets all property changes and created entities associated with the given group ID which have not been successfully submitted via #submitBatch. Resets also invalid user input for the same group ID. This function does not reset the deletion of entities (see sap.ui.model.odata.v4.Context#delete) and the execution of OData operations (see sap.ui.model.odata.v4.ODataContextBinding#execute).
|
setLegacySyntax |
Method not supported |
submitBatch |
Submits the requests associated with the given group ID in one batch request. Requests from subsequent calls to this method for the same group ID may be combined in one batch request using separate change sets. For group IDs with sap.ui.model.odata.v4.SubmitMode.Auto, only a single change set is used; this method is useful to repeat failed updates or creates (see sap.ui.model.odata.v4.ODataListBinding#create) together with all other requests for the given group ID in one batch request. |
toString |
Returns a string representation of this object including the service URL. |
See sap.ui.base.EventProvider#attachEvent
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
sEventId | string |
The identifier of the event to listen for |
|
_oData | object | ||
_fnFunction | function | ||
_oListener | object |
Attach event handler fnFunction
to the 'sessionTimeout' event of this model.
Param | Type | DefaultValue | Description |
---|---|---|---|
fnFunction | function |
The function to call when the event occurs |
|
oListener | object |
Object on which to call the given function |
Creates a new context binding for the given path, context and parameters.
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
sPath | string |
The binding path in the model; must not end with a slash |
|
oContext | sap.ui.model.odata.v4.Context |
The context which is required as base for a relative path |
|
mParameters | object |
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 as specified below. Note: The binding creates its own data service request if it is absolute or if it has any parameters or if it is relative and has a context created via #createBindingContext. The following OData query options are allowed:
|
|
$$canonicalPath | boolean |
Whether a binding relative to a sap.ui.model.odata.v4.Context uses the canonical path computed from its context's path for data service requests; only the value |
|
$$groupId | string |
The group ID to be used for read requests triggered by this binding; if not specified, either the parent binding's group ID (if the binding is relative) or the model's group ID is used, see sap.ui.model.odata.v4.ODataModel#constructor. Valid values are |
|
$$inheritExpandSelect | boolean |
For operation bindings only: Whether $expand and $select from the parent binding are used in the request sent on #execute. If set to |
|
$$ownRequest | boolean |
Whether the binding always uses an own service request to read its data; only the value |
|
$$patchWithoutSideEffects | boolean |
Whether implicit loading of side effects via PATCH requests is switched off; only the value |
|
$$updateGroupId | string |
The group ID to be used for update requests triggered by this binding; if not specified, either the parent binding's update group ID (if the binding is relative) or the model's update group ID is used, see sap.ui.model.odata.v4.ODataModel#constructor. For valid values, see parameter "$$groupId". |
Creates a new list binding for the given path and optional context which must resolve to an absolute OData path for an entity set.
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
sPath | string |
The binding path in the model; must not end with a slash |
|
oContext | sap.ui.model.Context |
The context which is required as base for a relative path |
|
vSorters | sap.ui.model.Sorter sap.ui.model.Sorter[] |
The dynamic sorters to be used initially. Call sap.ui.model.odata.v4.ODataListBinding#sort to replace them. Static sorters, as defined in the '$orderby' binding parameter, are always executed after the dynamic sorters. Supported since 1.39.0. |
|
vFilters | sap.ui.model.Filter sap.ui.model.Filter[] |
The dynamic application filters to be used initially. Call sap.ui.model.odata.v4.ODataListBinding#filter to replace them. Static filters, as defined in the '$filter' binding parameter, are always combined with the dynamic filters using a logical |
|
mParameters | object |
Map of binding parameters which can be OData query options as specified in "OData Version 4.0 Part 2: URL Conventions" or binding-specific parameters as specified below. Note: The binding creates its own data service request if it is absolute or if it has any parameters or if it is relative and has a context created via #createBindingContext or if it has sorters or filters. The following OData query options are allowed:
|
|
$$aggregation | object |
An object holding the information needed for data aggregation, see sap.ui.model.odata.v4.ODataListBinding#setAggregation for details. |
|
$$canonicalPath | boolean |
Whether a binding relative to a sap.ui.model.odata.v4.Context uses the canonical path computed from its context's path for data service requests; only the value |
|
$$groupId | string |
The group ID to be used for read requests triggered by this binding; if not specified, either the parent binding's group ID (if the binding is relative) or the model's group ID is used, see sap.ui.model.odata.v4.ODataModel#constructor. Valid values are |
|
$$operationMode | sap.ui.model.odata.OperationMode |
The operation mode for filtering and sorting with the model's operation mode as default. Since 1.39.0, the operation mode sap.ui.model.odata.OperationMode.Server is supported. All other operation modes including |
|
$$patchWithoutSideEffects | boolean |
Whether implicit loading of side effects via PATCH requests is switched off; only the value |
|
$$ownRequest | boolean |
Whether the binding always uses an own service request to read its data; only the value |
|
$$sharedRequest | boolean |
Whether multiple bindings for the same resource path share the data, so that it is requested only once; only the value
|
|
$$updateGroupId | string |
The group ID to be used for update requests triggered by this binding; if not specified, either the parent binding's update group ID (if the binding is relative) or the model's update group ID is used, see sap.ui.model.odata.v4.ODataModel#constructor. For valid values, see parameter "$$groupId". |
Creates a new property binding for the given path. This binding is inactive and will not know the property value initially. You have to call sap.ui.model.Binding#initialize to get it updated asynchronously and register a change listener at the binding to be informed when the value is available.
It is possible to create a property binding pointing to metadata. A '##' in the binding's path is recognized as a separator and splits it into two parts. The part before the separator is resolved with the binding's context and the result is transformed into a metadata context (see sap.ui.model.odata.v4.ODataMetaModel#getMetaContext). The part following the separator is then interpreted relative to this metadata context, even if it starts with a '/'; see sap.ui.model.odata.v4.ODataMetaModel#requestObject for more details.
If the target type specified in the corresponding control property's binding info is "any" and the binding is relative or points to metadata, the binding may have an object value; in this case and unless the binding refers to an action advertisement the binding's mode must be sap.ui.model.BindingMode.OneTime.
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
sPath | string |
The binding path in the model; must not end with a slash |
|
oContext | sap.ui.model.Context |
The context which is required as base for a relative path |
|
mParameters | object |
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 as specified below. The following OData query options are allowed:
|
|
$$groupId | string |
The group ID to be used for read requests triggered by this binding; if not specified, either the parent binding's group ID (if the binding is relative) or the model's group ID is used, see sap.ui.model.odata.v4.ODataModel#constructor. Valid values are |
|
$$ignoreMessages | boolean |
Whether this binding does not propagate model messages to the control; supported since 1.82.0. Some composite types like sap.ui.model.odata.type.Currency or sap.ui.model.odata.type.Unit automatically ignore messages for some of their parts depending on their format options; setting this parameter to For example, a binding for a currency code is used in a composite binding for rendering the proper number of decimals, but the currency code is not displayed in the attached control. In that case, messages for the currency code shall not be displayed at that control, only messages for the amount. |
|
$$noPatch | boolean |
Whether changing the value of this property binding is not causing a PATCH request; only the value |
Method not supported
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
_sPath | string | ||
_oContext | sap.ui.model.Context | ||
_aFilters | sap.ui.model.Filter[] | ||
_mParameters | object | ||
_aSorters | sap.ui.model.Sorter[] |
Changes the HTTP headers used for data and metadata requests sent by this model.
If batch requests are used, the headers will be set for the batch itself, as well as for the individual requests within the batch. The headers are changed according to the given map of headers: Headers with an undefined
value are removed, the other headers are set, and missing headers remain unchanged. The following headers must not be used:
If not undefined
, a header value must conform to the following rules:
Param | Type | DefaultValue | Description |
---|---|---|---|
mHeaders | object |
Map of HTTP header names to their values |
Creates a binding context for the given path. A relative path can only be resolved if a context is provided. Note: The parameters mParameters
, fnCallBack
, and bReload
from sap.ui.model.Model#createBindingContext are not supported.
It is possible to create binding contexts pointing to metadata. A '##' is recognized as separator in the resolved path and splits it into two parts; note that '#' may also be used as separator but is deprecated since 1.51. The part before the separator is transformed into a metadata context (see sap.ui.model.odata.v4.ODataMetaModel#getMetaContext). The part following the separator is then interpreted relative to this metadata context, even if it starts with a '/'; a trailing '/' is allowed here, see sap.ui.model.odata.v4.ODataMetaModel#requestObject for the effect it has.
A binding path may also point to an operation advertisement which is addressed with '#
Examples:
/Products('42')/Name##@com.sap.vocabularies.Common.v1.Label
points to the "Label" annotation of the "Name" property of the entity set "Products". /##Products/Name@com.sap.vocabularies.Common.v1.Label
has no data path part and thus starts at the metadata root. It also points to the "Label" annotation of the "Name" property of the entity set "Products". /Products##/
points to the entity type (note the trailing '/') of the entity set "Products". /EMPLOYEES('1')/##com.sap.Action
points to the metadata of an action bound to the entity set "EMPLOYEES". /EMPLOYEES('1')/#com.sap.Action
does not point to metadata, but to the action advertisement. Param | Type | DefaultValue | Description |
---|---|---|---|
sPath | string |
The binding path, may be relative to the provided context |
|
oContext | sap.ui.model.Context |
The context which is required as base for a relative path |
Destroys this model, its requestor and its meta model.
References:
Detach event handler fnFunction
from the 'sessionTimeout' event of this model.
Param | Type | DefaultValue | Description |
---|---|---|---|
fnFunction | function |
The function to call when the event occurs |
|
oListener | object |
Object on which to call the given function |
Creates a new subclass of class sap.ui.model.odata.v4.ODataModel 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.Model.extend.
Param | Type | DefaultValue | Description |
---|---|---|---|
sClassName | string |
Name of the class being created |
|
oClassInfo | object |
Object literal with information about the class |
|
FNMetaImpl | function |
Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class |
Returns a map of HTTP headers used for data and metadata requests. While the "X-CSRF-Token" header is not used for metadata requests, it is still included here if available. The "SAP-ContextId" header is only included if requested explicitly (@since 1.86.0).
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
bIncludeContextId | boolean |
Whether to include the "SAP-ContextId" header (@since 1.86.0) |
Returns messages of this model associated with the given context, that is messages belonging to the object referred to by this context or a child object of that object. The messages are sorted by their type according to the type's severity in a way that messages with highest severity come first.
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
oContext | sap.ui.model.Context |
The context to retrieve messages for |
Returns a metadata object for class sap.ui.model.odata.v4.ODataModel.
Returns the model's update group ID.
References:
Returns true
if there are pending changes, meaning updates or created entities (see sap.ui.model.odata.v4.ODataListBinding#create) that have not yet been successfully sent to the server.
Param | Type | DefaultValue | Description |
---|---|---|---|
sGroupId | string |
A group ID as specified in sap.ui.model.odata.v4.ODataModel, except group IDs having sap.ui.model.odata.v4.SubmitMode.Direct; if specified, only pending changes related to that group ID are considered (since 1.70.0) |
Refreshes the model by calling refresh on all bindings which have a change event handler attached.
Note: When calling #refresh multiple times, the result of the request triggered by the last call determines the model's data; it is independent of the order of calls to #submitBatch with the given group ID.
If there are pending changes, an error is thrown. Use #hasPendingChanges to check if there are pending changes. If there are changes, call #submitBatch to submit the changes or #resetChanges to reset the changes before calling #refresh.
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
sGroupId | string boolean |
The group ID to be used for refresh; valid values are |
Returns a promise for the "canonical path" of the entity for the given context. According to "4.3.1 Canonical URL" of the specification "OData Version 4.0 Part 2: URL Conventions", this is the "name of the entity set associated with the entity followed by the key predicate identifying the entity within the collection". Use the canonical path in sap.ui.core.Element#bindElement to create an element binding.
Param | Type | DefaultValue | Description |
---|---|---|---|
oEntityContext | sap.ui.model.odata.v4.Context |
A context in this model which must point to a non-contained OData entity |
Resets all property changes and created entities associated with the given group ID which have not been successfully submitted via #submitBatch. Resets also invalid user input for the same group ID. This function does not reset the deletion of entities (see sap.ui.model.odata.v4.Context#delete) and the execution of OData operations (see sap.ui.model.odata.v4.ODataContextBinding#execute).
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
sGroupId | string |
A valid group ID as specified in sap.ui.model.odata.v4.ODataModel. If it is |
Submits the requests associated with the given group ID in one batch request. Requests from subsequent calls to this method for the same group ID may be combined in one batch request using separate change sets. For group IDs with sap.ui.model.odata.v4.SubmitMode.Auto, only a single change set is used; this method is useful to repeat failed updates or creates (see sap.ui.model.odata.v4.ODataListBinding#create) together with all other requests for the given group ID in one batch request.
Param | Type | DefaultValue | Description |
---|---|---|---|
sGroupId | string |
A valid group ID as specified in sap.ui.model.odata.v4.ODataModel. |