Class sap.ui.model.odata.ODataModelModule: sap/ui/model/odata/ODataModel

extends Model

Model implementation for oData format
Deprecated API:
Constructor Summary
new sap.ui.model.odata.ODataModel(sServiceUrl?, mParameters?)Constructor for a new ODataModel.
Method Summary
sap.ui.model.odata.ODataModel.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.odata.ODataModel with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.odata.ODataModel.getMetadata()Returns a metadata object for class sap.ui.model.odata.ODataModel.
addAnnotationUrl(vUrl)Adds (a) new URL(s) to the be parsed for OData annotations, which are then merged into the annotations object which can be retrieved by calling the getServiceAnnotations()-method.
addAnnotationXML(sXMLContent, bSuppressEvents?)Adds new xml content to be parsed for OData annotations, which are then merged into the annotations object which can be retrieved by calling the getServiceAnnotations()-method.
addBatchChangeOperations(aChangeOperations)Appends the change batch operations to the end of the batch stack.
addBatchReadOperations(aReadOperations)Appends the read batch operations to the end of the batch stack.
attachAnnotationsFailed(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'annotationsFailed' event of this sap.ui.model.odata.ODataModel.
attachAnnotationsLoaded(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'annotationsLoaded' event of this sap.ui.model.odata.ODataModel.
attachMetadataFailed(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'metadataFailed' event of this sap.ui.model.odata.ODataModel.
attachMetadataLoaded(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'metadataLoaded' event of this sap.ui.model.odata.ODataModel.
bindList(sPath, oContext?, aSorters?, aFilters?, mParameters?)Creates a new list binding for this model.
callFunction(sFunctionName, mParameters?)Trigger a request to the function import odata service that was specified in the model constructor.
clearBatch()Removes all operations in the current batch.
create(sPath, oData, mParameters?)Trigger a POST request to the odata service that was specified in the model constructor.
createBatchOperation(sPath, sMethod, oData?, oParameters?)Creates a single batch operation (read or change operation) which can be used in a batch request.
createEntry(sPath, vProperties)Creates a new entry object which is described by the metadata of the entity type of the specified sPath Name.
createKey(sCollection, oKeyParameters, bDecode)Creates the key from the given collection name and property map
deleteCreatedEntry(oContext)Deletes a created entry from the request queue and the model.
detachAnnotationsFailed(fnFunction, oListener)Detach event-handler fnFunction from the 'annotationsFailed' event of this sap.ui.model.odata.ODataModel.
detachAnnotationsLoaded(fnFunction, oListener)Detach event-handler fnFunction from the 'annotationsLoaded' event of this sap.ui.model.odata.ODataModel.
detachMetadataFailed(fnFunction, oListener)Detach event-handler fnFunction from the 'metadataFailed' event of this sap.ui.model.odata.ODataModel.
detachMetadataLoaded(fnFunction, oListener)Detach event-handler fnFunction from the 'metadataLoaded' event of this sap.ui.model.odata.ODataModel.
fireAnnotationsFailed(mArguments?)Fire event annotationsFailed to attached listeners.
fireAnnotationsLoaded(mArguments?)Fire event annotationsLoaded to attached listeners.
fireMetadataFailed(mArguments?)Fire event metadataFailed to attached listeners.
fireMetadataLoaded(mArguments?)Fire event metadataLoaded to attached listeners.
getDefaultCountMode()Returns the default count mode for retrieving the count of collections
getHeaders()Returns all headers and custom headers which are stored in the OData model.
getKey(oObject, bDecode)Returns the key part from the entry URI or the given context or object
getMetaModel()Returns an instance of an OData meta model which offers a unified access to both OData V2 metadata and V4 annotations.
getProperty(sPath, oContext?, bIncludeExpandEntries?)Returns the value for the property with the given sPath.
getSecurityToken()Returns the current security token.
getServiceAnnotations()Return the annotation object.
getServiceMetadata()Return the metadata object.
hasPendingChanges()Checks if there exist pending changes in the model created by the setProperty method.
read(sPath, mParameters?)Trigger a GET request to the odata service that was specified in the model constructor.
refresh(bForceUpdate?, bRemoveData?)Refresh the model.
refreshMetadata()refreshes the metadata for model, e.g.
refreshSecurityToken(fnSuccess?, fnError?, bAsync?)refresh XSRF token by performing a GET request against the service root URL.
remove(sPath, mParameters?)Trigger a DELETE request to the odata service that was specified in the model constructor.
resetChanges(fnSuccess?, fnError?)Resets the collected changes by the setProperty method and reloads the data from the server.
setDefaultCountMode(sCountMode)Sets the default mode how to retrieve the item count for a collection in this model.
setHeaders(mHeaders)Set custom headers which are provided in a key/value map.
setProperty(sPath, oValue, oContext?, bAsyncUpdate?)Sets a new value for the given property sPropertyName in the model without triggering a server request.
setRefreshAfterChange(bRefreshAfterChange)Enable/Disable automatic updates of all Bindings after change operations
setTokenHandlingEnabled(bTokenHandling?)Enable/Disable XCSRF-Token handling
setUseBatch(bUseBatch?)Enable/Disable batch for all requests
submitBatch(fnSuccess?, fnError?, bAsync?, bImportData)Submits the collected changes in the batch which were collected via addBatchReadOperations or addBatchChangeOperations.
submitChanges(fnSuccess?, fnError?, oParameters?)Submits the collected changes which were collected by the setProperty method.
update(sPath, oData, mParameters?)Trigger a PUT/MERGE request to the odata service that was specified in the model constructor.
updateBindings(bForceUpdate?)update all bindings
forceNoCache(bForceNoCache?)Force no caching
getData(sPath, oContext?, bIncludeExpandEntries?)Return requested data as object if the data has already been loaded and stored in the model.
isCountSupported()Returns whether this model supports the $count on its collections This method is deprecated, please use getDefaultCountMode instead.
setCountSupported(bCountSupported)Sets whether this OData service supports $count on its collections.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.odata.ODataModel(sServiceUrl?, mParameters?)
Constructor for a new ODataModel.
Parameters:
stringsServiceUrl?base uri of the service to request data from; additional URL parameters appended here will be appended to every request can be passed with the mParameters object as well: [mParameters.serviceUrl] A serviceURl is required!
objectmParameters?(optional) a map which contains the following parameter properties:
booleanmParameters.json?if set true request payloads will be JSON, XML for false (default = false),
stringmParameters.user?user for the service,
stringmParameters.password?password for service,
mapmParameters.headers?a map of custom headers like {"myHeader":"myHeaderValue",...},
booleanmParameters.tokenHandling?enable/disable XCSRF-Token handling (default = true),
booleanmParameters.withCredentials?experimental - true when user credentials are to be included in a cross-origin request. Please note that this works only if all requests are asynchronous.
objectmParameters.loadMetadataAsync?(optional) determined if the service metadata request is sent synchronous or asynchronous. Default is false.
mParameters.maxDataServiceVersion?(default = '2.0') please use the following string format e.g. '2.0' or '3.0'. OData version supported by the ODataModel: '2.0',
booleanmParameters.useBatch?when true all requests will be sent in batch requests (default = false),
booleanmParameters.refreshAfterChange?enable/disable automatic refresh after change operations: default = true,
string|string[]mParameters.annotationURI?The URL (or an array of URLs) from which the annotation metadata should be loaded,
booleanmParameters.loadAnnotationsJoined?Whether or not to fire the metadataLoaded-event only after annotations have been loaded as well,
mapmParameters.serviceUrlParams?map of URL parameters - these parameters will be attached to all requests,
mapmParameters.metadataUrlParams?map of URL parameters for metadata requests - only attached to $metadata request.
stringmParameters.defaultCountMode?sets the default count mode for the model. If not set, sap.ui.model.odata.CountMode.Both is used.
mapmParameters.metadataNamespaces?a map of namespaces (name => URI) used for parsing the service metadata.
booleanmParameters.skipMetadataAnnotationParsing?Whether to skip the automated loading of annotations from the metadata document. Loading annotations from metadata does not have any effects (except the lost performance by invoking the parser) if there are not annotations inside the metadata document
Method Detail
sap.ui.model.odata.ODataModel.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.ui.model.odata.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.

Parameters:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.ui.model.odata.ODataModel.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.odata.ODataModel.
Returns:
sap.ui.base.MetadataMetadata object describing this class
addAnnotationUrl(vUrl): Promise
Adds (a) new URL(s) to the be parsed for OData annotations, which are then merged into the annotations object which can be retrieved by calling the getServiceAnnotations()-method. If a $metadata url is passed the data will also be merged into the metadata object, which can be reached by calling the getServiceMetadata() method.
Parameters:
string|string[]vUrlEither one URL as string or an array or URL strings
Returns:
PromiseThe Promise to load the given URL(s), resolved if all URLs have been loaded, rejected if at least one fails to load. If this promise resolves it returns the following parameters: annotations: The annotation object entitySets: An array of EntitySet objects containing the newly merged EntitySets from a $metadata requests. the structure is the same as in the metadata object reached by the getServiceMetadata() method. For non $metadata requests the array will be empty.
addAnnotationXML(sXMLContent, bSuppressEvents?): Promise
Adds new xml content to be parsed for OData annotations, which are then merged into the annotations object which can be retrieved by calling the getServiceAnnotations()-method.
Parameters:
stringsXMLContentThe string that should be parsed as annotation XML
booleanbSuppressEvents?, Default: falseWhether not to fire annotationsLoaded event on the annotationParser
Returns:
PromiseThe Promise to parse the given XML-String, resolved if parsed without errors, rejected if errors occur
addBatchChangeOperations(aChangeOperations)
Appends the change batch operations to the end of the batch stack. Only PUT, POST or DELETE batch operations should be included in the specified array. The operations in the array will be included in a single changeset. To embed change operations in different change sets call this method with the corresponding change operations again. If an illegal batch operation is added to the change set nothing will be performed and false will be returned.
Parameters:
any[]aChangeOperationsan array of change batch operations created via createBatchOperation and sMethod = POST, PUT, MERGE or DELETE
addBatchReadOperations(aReadOperations)
Appends the read batch operations to the end of the batch stack. Only GET batch operations should be included in the specified array. If an illegal batch operation is added to the batch nothing will be performed and false will be returned.
Parameters:
any[]aReadOperationsan array of read batch operations created via createBatchOperation and sMethod = GET
attachAnnotationsFailed(oData?, fnFunction, oListener?): sap.ui.model.odata.ODataModel
Attach event-handler fnFunction to the 'annotationsFailed' event of this sap.ui.model.odata.ODataModel.
Parameters:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, the global context (window) is used.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
attachAnnotationsLoaded(oData?, fnFunction, oListener?): sap.ui.model.odata.ODataModel
Attach event-handler fnFunction to the 'annotationsLoaded' event of this sap.ui.model.odata.ODataModel.
Parameters:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, the global context (window) is used.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
attachMetadataFailed(oData?, fnFunction, oListener?): sap.ui.model.odata.ODataModel
Attach event-handler fnFunction to the 'metadataFailed' event of this sap.ui.model.odata.ODataModel.
Parameters:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, the global context (window) is used.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
attachMetadataLoaded(oData?, fnFunction, oListener?): sap.ui.model.odata.ODataModel
Attach event-handler fnFunction to the 'metadataLoaded' event of this sap.ui.model.odata.ODataModel.
Parameters:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, the global context (window) is used.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
bindList(sPath, oContext?, aSorters?, aFilters?, mParameters?): sap.ui.model.ListBinding
Creates a new list binding for this model.
Parameters:
stringsPathBinding path, either absolute or relative to a given oContext
sap.ui.model.ContextoContext?, Default: Binding context referring to this model
sap.ui.model.Sorter|sap.ui.model.Sorter[]aSorters?, Default: Initial sort order, can be either a sorter or an array of sorters
sap.ui.model.Filter|sap.ui.model.Filter[]aFilters?, Default: Predefined filter/s, can be either a filter or an array of filters
mapmParameters?Map which contains additional parameters for the binding
stringmParameters.expand?Value for the OData $expand query parameter which should be included in the request
stringmParameters.select?Value for the OData $select query parameter which should be included in the request
mapmParameters.custom?Optional map of custom query parameters (name/value pairs); names of custom parameters must not start with $
sap.ui.model.odata.CountModemParameters.countMode?Defines the count mode of the new binding; if not specified, the default count mode of this model will be applied
Returns:
sap.ui.model.ListBindingoBinding new list binding object
See:
sap.ui.model.Model#bindList
callFunction(sFunctionName, mParameters?): object
Trigger a request to the function import odata service that was specified in the model constructor.
Parameters:
stringsFunctionNameA string containing the name of the function to call. The name is concatenated to the sServiceUrl which was specified in the model constructor.
mapmParameters?Optional parameter map containing any of the following properties:
stringmParameters.method?A string containing the type of method to call this function with
mapmParameters.urlParameters?A map containing the parameters that will be passed as query strings
objectmParameters.context?If specified the sPath has to be relative to the path given with the context.
functionmParameters.success?a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response.
functionmParameters.error?a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information.
booleanmParameters.async?, Default: falseWhether or not to send the request asynchronously. Default: false In case sMethod is "GET", the request is always asynchronous. Please be advised that this feature is officially unsupported as using asynchronous requests can lead to data inconsistencies if the application does not make sure that the request was completed before continuing to work with the data.
Returns:
objectan object which has an abort function to abort the current request.
clearBatch()
Removes all operations in the current batch.
create(sPath, oData, mParameters?): object
Trigger a POST request to the odata service that was specified in the model constructor. Please note that deep creates are not supported and may not work.
Parameters:
stringsPathA string containing the path to the collection where an entry should be created. The path is concatenated to the sServiceUrl which was specified in the model constructor.
objectoDatadata of the entry that should be created.
mapmParameters?Optional parameter map containing any of the following properties:
objectmParameters.context?If specified the sPath has to be relative to the path given with the context.
functionmParameters.success?a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response.
functionmParameters.error?a callback function which is called when the request failed. The handler can have the parameter oError which contains additional error information.
booleanmParameters.async?, Default: falseWhether the request should be done asynchronously. Default: false Please be advised that this feature is officially unsupported as using asynchronous requests can lead to data inconsistencies if the application does not make sure that the request was completed before continuing to work with the data.
mapmParameters.urlParameters?A map containing the parameters that will be passed as query strings
Returns:
objectan object which has an abort function to abort the current request.
createBatchOperation(sPath, sMethod, oData?, oParameters?)
Creates a single batch operation (read or change operation) which can be used in a batch request.
Parameters:
stringsPathA string containing the path to the collection or entry where the batch operation should be performed. The path is concatenated to the sServiceUrl which was specified in the model constructor.
stringsMethodfor the batch operation. Possible values are GET, PUT, MERGE, POST, DELETE
objectoData?optional data payload which should be created, updated, deleted in a change batch operation.
objectoParameters?optional parameter for additional information introduced in SAPUI5 1.9.1,
stringoParameters.sETag?an ETag which can be used for concurrency control. If it is specified, it will be used in an If-Match-Header in the request to the server for this entry.
createEntry(sPath, vProperties): sap.ui.model.Context

Creates a new entry object which is described by the metadata of the entity type of the specified sPath Name. A context object is returned which can be used to bind against the newly created object.

For each created entry a request is created and stored in a request queue. The request queue can be submitted by calling submitChanges. To delete a created entry from the request queue call deleteCreateEntry.

The optional vProperties parameter can be used as follows:

- vProperties could be an array containing the property names which should be included in the new entry. Other properties defined in the entity type are not included. - vProperties could be an object which includes the desired properties and the values which should be used for the created entry.

If vProperties is not specified, all properties in the entity type will be included in the created entry.

If there are no values specified the properties will have undefined values.

Please note that deep creates (including data defined by navigationproperties) are not supported

Parameters:
StringsPathName of the path to the collection
array|objectvPropertiesAn array that specifies a set of properties or the entry
Returns:
sap.ui.model.ContextoContext A Context object that point to the new created entry.
createKey(sCollection, oKeyParameters, bDecode)
Creates the key from the given collection name and property map
Parameters:
stringsCollectionThe name of the collection
objectoKeyParametersThe object containing at least all the key properties of the entity type
booleanbDecodeWhether the URI decoding should be applied on the key
deleteCreatedEntry(oContext)
Deletes a created entry from the request queue and the model.
Parameters:
sap.ui.model.ContextoContextThe context object pointing to the created entry
detachAnnotationsFailed(fnFunction, oListener): sap.ui.model.odata.ODataModel

Detach event-handler fnFunction from the 'annotationsFailed' event of this sap.ui.model.odata.ODataModel.

The passed function and listener object must match the ones previously used for event registration.

Parameters:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
detachAnnotationsLoaded(fnFunction, oListener): sap.ui.model.odata.ODataModel
Detach event-handler fnFunction from the 'annotationsLoaded' event of this sap.ui.model.odata.ODataModel.
Parameters:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
detachMetadataFailed(fnFunction, oListener): sap.ui.model.odata.ODataModel

Detach event-handler fnFunction from the 'metadataFailed' event of this sap.ui.model.odata.ODataModel.

The passed function and listener object must match the ones previously used for event registration.

Parameters:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
detachMetadataLoaded(fnFunction, oListener): sap.ui.model.odata.ODataModel

Detach event-handler fnFunction from the 'metadataLoaded' event of this sap.ui.model.odata.ODataModel.

The passed function and listener object must match the ones previously used for event registration.

Parameters:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
fireAnnotationsFailed(mArguments?): sap.ui.model.odata.ODataModel
Fire event annotationsFailed to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
stringmArguments.message?A text that describes the failure.
stringmArguments.statusCode?HTTP status code returned by the request (if available)
stringmArguments.statusText?The status as a text, details not specified, intended only for diagnosis output
stringmArguments.responseText?Response that has been received for the request ,as a text string
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
fireAnnotationsLoaded(mArguments?): sap.ui.model.odata.ODataModel
Fire event annotationsLoaded to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
sap.ui.model.odata.ODataAnnotationsmArguments.annotations?the annotations object.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
fireMetadataFailed(mArguments?): sap.ui.model.odata.ODataModel
Fire event metadataFailed to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
stringmArguments.message?A text that describes the failure.
stringmArguments.statusCode?HTTP status code returned by the request (if available)
stringmArguments.statusText?The status as a text, details not specified, intended only for diagnosis output
stringmArguments.responseText?Response that has been received for the request ,as a text string
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
fireMetadataLoaded(mArguments?): sap.ui.model.odata.ODataModel
Fire event metadataLoaded to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
sap.ui.model.odata.ODataMetadatamArguments.metadata?the metadata object.
Returns:
sap.ui.model.odata.ODataModelthis to allow method chaining
getDefaultCountMode(): sap.ui.model.odata.CountMode
Returns the default count mode for retrieving the count of collections
Returns:
sap.ui.model.odata.CountMode
Since:
1.20
getHeaders(): object
Returns all headers and custom headers which are stored in the OData model.
Returns:
objectthe header map
getKey(oObject, bDecode)
Returns the key part from the entry URI or the given context or object
Parameters:
object|sap.ui.model.ContextoObjectThe context or object
booleanbDecodeWhether the URI decoding should be applied on the key

Returns an instance of an OData meta model which offers a unified access to both OData V2 metadata and V4 annotations. It uses the existing sap.ui.model.odata.ODataMetadata as a foundation and merges V4 annotations from the existing sap.ui.model.odata.ODataAnnotations directly into the corresponding model element.

BEWARE: Access to this OData meta model will fail before the promise returned by loaded has been resolved!

Returns:
sap.ui.model.odata.ODataMetaModelThe meta model for this ODataModel
getProperty(sPath, oContext?, bIncludeExpandEntries?)
Returns the value for the property with the given sPath. If the path points to a navigation property which has been loaded via $expand then the bIncludeExpandEntries parameter determines if the navigation property should be included in the returned value or not. Please note that this currently works for 1..1 navigation properties only.
Parameters:
stringsPaththe path/name of the property
objectoContext?the context if available to access the property value
booleanbIncludeExpandEntries?, Default: This parameter should be set when a URI or custom parameter with a $expand System Query Option was used to retrieve associated entries embedded/inline. If true then the getProperty function returns a desired property value/entry and includes the associated expand entries (if any). If false the associated/expanded entry properties are removed and not included in the desired entry as properties at all. This is useful for performing updates on the base entry only. Note: A copy and not a reference of the entry will be returned.
getSecurityToken(): string
Returns the current security token. If the token has not been requested from the server it will be requested first.
Returns:
stringthe CSRF security token
getServiceAnnotations(): Object
Return the annotation object. Please note that when using the model with bLoadMetadataAsync = true then this function might return undefined because the metadata has not been loaded yet. In this case attach to the annotationsLoaded event to get notified when the annotations are available and then call this function.
Returns:
Objectmetdata object
getServiceMetadata(): Object
Return the metadata object. Please note that when using the model with bLoadMetadataAsync = true then this function might return undefined because the metadata has not been loaded yet. In this case attach to the metadataLoaded event to get notified when the metadata is available and then call this function.
Returns:
Objectmetdata object
hasPendingChanges(): boolean
Checks if there exist pending changes in the model created by the setProperty method.
Returns:
booleantrue/false
read(sPath, mParameters?): object
Trigger a GET request to the odata service that was specified in the model constructor. The data will not be stored in the model. The requested data is returned with the response.
Parameters:
stringsPathA string containing the path to the data which should be retrieved. The path is concatenated to the sServiceUrl which was specified in the model constructor.
mapmParameters?Optional parameter map containing any of the following properties:
objectmParameters.context?If specified the sPath has to be is relative to the path given with the context.
mapmParameters.urlParameters?A map containing the parameters that will be passed as query strings
booleanmParameters.async?, Default: truetrue for asynchronous requests.
arraymParameters.filters?an array of sap.ui.model.Filter to be included in the request URL
arraymParameters.sorters?an array of sap.ui.model.Sorter to be included in the request URL
functionmParameters.success?a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response.
functionmParameters.error?a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information.
Returns:
objectan object which has an abort function to abort the current request.
refresh(bForceUpdate?, bRemoveData?)
Refresh the model. This will check all bindings for updated data and update the controls if data has been changed.
Parameters:
booleanbForceUpdate?, Default: falseForce update of controls
booleanbRemoveData?, Default: falseIf set to true then the model data will be removed/cleared. Please note that the data might not be there when calling e.g. getProperty too early before the refresh call returned.
refreshMetadata()
refreshes the metadata for model, e.g. in case the first request for metadata has failed
refreshSecurityToken(fnSuccess?, fnError?, bAsync?): object
refresh XSRF token by performing a GET request against the service root URL.
Parameters:
functionfnSuccess?a callback function which is called when the data has been successfully retrieved.
functionfnError?a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information.
booleanbAsync?, Default: falsetrue for asynchronous requests.
Returns:
objectan object which has an abort function to abort the current request.
remove(sPath, mParameters?): object
Trigger a DELETE request to the odata service that was specified in the model constructor.
Parameters:
stringsPathA string containing the path to the data that should be removed. The path is concatenated to the sServiceUrl which was specified in the model constructor.
objectmParameters?Optional, can contain the following attributes: oContext, fnSuccess, fnError, sETag:
objectmParameters.context?If specified the sPath has to be relative to the path given with the context.
functionmParameters.success?a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response.
functionmParameters.error?a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information.
stringmParameters.eTag?If specified, the If-Match-Header will be set to this Etag.
objectmParameters.payload?if specified, this optional variable can be used to pass a payload into the delete function, e.g. if the entry which should be deleted has not been bound to any control, but has been retrieved via read, only.
booleanmParameters.async?, Default: falseWhether the request should be done asynchronously. Please be advised that this feature is officially unsupported as using asynchronous requests can lead to data inconsistencies if the application does not make sure that the request was completed before continuing to work with the data.
mapmParameters.urlParameters?A map containing the parameters that will be passed as query strings
Returns:
objectan object which has an abort function to abort the current request.
resetChanges(fnSuccess?, fnError?)
Resets the collected changes by the setProperty method and reloads the data from the server.
Parameters:
functionfnSuccess?a callback function which is called when the data has been successfully resetted. The handler can have the following parameters: oData and response.
functionfnError?a callback function which is called when the request failed
setDefaultCountMode(sCountMode)

Sets the default mode how to retrieve the item count for a collection in this model.

The count can be determined in the following ways

  • by sending a separate $count request
  • by adding parameter $inlinecount=allpages to one or all data requests
  • a combination of the previous two
  • not at all (questions about the size of the collection can't be answered then)

See sap.ui.model.odata.CountMode for all enumeration values and more details.

Note that a call to this method does not modify the count mode for existing list bindings, only bindings that are created afterwards will use the new mode when no mode is defined at their creation.

If no default count mode is set for an ODataModel (v1), the mode Both will be used for compatibility reasons.

Parameters:
sap.ui.model.odata.CountModesCountModeThe new default count mode for this model
Since:
1.20
setHeaders(mHeaders)

Set custom headers which are provided in a key/value map. These headers are used for requests against the OData backend. Private headers which are set in the ODataModel cannot be modified. These private headers are: accept, accept-language, x-csrf-token, MaxDataServiceVersion, DataServiceVersion.

To remove these headers simply set the mCustomHeaders parameter to null. Please also note that when calling this method again all previous custom headers are removed unless they are specified again in the mCustomHeaders parameter.

Parameters:
objectmHeadersthe header name/value map.
setProperty(sPath, oValue, oContext?, bAsyncUpdate?): boolean

Sets a new value for the given property sPropertyName in the model without triggering a server request. This can be done by the submitChanges method.

Note: Only one entry of one collection can be updated at once. Otherwise a fireRejectChange event is fired.

Before updating a different entry the existing changes of the current entry have to be submitted or resetted by the corresponding methods: submitChanges, resetChanges.

IMPORTANT: All pending changes are resetted in the model if the application triggeres any kind of refresh on that entry. Make sure to submit the pending changes first. To determine if there are any pending changes call the hasPendingChanges method.

Parameters:
stringsPathpath of the property to set
anyoValuevalue to set the property to
objectoContext?, Default: the context which will be used to set the property
booleanbAsyncUpdate?whether to update other bindings dependent on this property asynchronously
Returns:
booleantrue if the value was set correctly and false if errors occurred like the entry was not found or another entry was already updated.
setRefreshAfterChange(bRefreshAfterChange)
Enable/Disable automatic updates of all Bindings after change operations
Parameters:
booleanbRefreshAfterChange
Since:
1.16.3
setTokenHandlingEnabled(bTokenHandling?)
Enable/Disable XCSRF-Token handling
Parameters:
booleanbTokenHandling?, Default: truewhether to use token handling or not
setUseBatch(bUseBatch?)
Enable/Disable batch for all requests
Parameters:
booleanbUseBatch?, Default: falsewhether the requests should be encapsulated in a batch request
submitBatch(fnSuccess?, fnError?, bAsync?, bImportData): object
Submits the collected changes in the batch which were collected via addBatchReadOperations or addBatchChangeOperations. The batch will be cleared afterwards. If the batch is empty no request will be performed and false will be returned. Note: No data will be stored in the model.
Parameters:
functionfnSuccess?a callback function which is called when the batch request has been successfully sent. Note: There might have errors occured in the single batch operations. These errors can be accessed in the aErrorResponses parameter in the callback handler. The handler can have the following parameters: oData, oResponse and aErrorResponses.
functionfnError?a callback function which is called when the batch request failed. The handler can have the parameter: oError which contains additional error information.
booleanbAsync?true for asynchronous request. Default is true.
booleanbImportData
Returns:
objectan object which has an abort function to abort the current request. Returns false if no request will be performed because the batch is empty.
submitChanges(fnSuccess?, fnError?, oParameters?): object
Submits the collected changes which were collected by the setProperty method. A MERGE request will be triggered to only update the changed properties. If a URI with a $expand System Query Option was used then the expand entries will be removed from the collected changes. Changes to this entries should be done on the entry itself. So no deep updates are supported.
Parameters:
functionfnSuccess?a callback function which is called when the data has been successfully updated. The handler can have the following parameters: oData and response.
functionfnError?a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information
objectoParameters?optional parameter for additional information introduced in SAPUI5 1.9.1
stringoParameters.sETag?an ETag which can be used for concurrency control. If it is specified, it will be used in an If-Match-Header in the request to the server for this entry.
Returns:
objectan object which has an abort function to abort the current request.
update(sPath, oData, mParameters?): object
Trigger a PUT/MERGE request to the odata service that was specified in the model constructor. Please note that deep updates are not supported and may not work. These should be done seperate on the entry directly.
Parameters:
stringsPathA string containing the path to the data that should be updated. The path is concatenated to the sServiceUrl which was specified in the model constructor.
objectoDatadata of the entry that should be updated.
mapmParameters?Optional, can contain the following attributes:
objectmParameters.context?If specified the sPath has to be is relative to the path given with the context.
functionmParameters.success?a callback function which is called when the data has been successfully updated.
functionmParameters.error?a callback function which is called when the request failed. The handler can have the parameter oError which contains additional error information.
booleanmParameters.merge?, Default: falsetrigger a MERGE request instead of a PUT request to perform a differential update
stringmParameters.eTag?If specified, the If-Match-Header will be set to this Etag.
booleanmParameters.async?, Default: falseWhether the request should be done asynchronously. Please be advised that this feature is officially unsupported as using asynchronous requests can lead to data inconsistencies if the application does not make sure that the request was completed before continuing to work with the data.
mapmParameters.urlParameters?A map containing the parameters that will be passed as query strings
Returns:
objectan object which has an abort function to abort the current request.
updateBindings(bForceUpdate?)
update all bindings
Parameters:
booleanbForceUpdate?, Default: falseIf set to false an update will only be done when the value of a binding changed.
forceNoCache(bForceNoCache?)
Force no caching
Parameters:
booleanbForceNoCache?, Default: falsewhether to force no caching
Deprecated API:
The caching should be controlled by the backend by setting the correct cache control header
getData(sPath, oContext?, bIncludeExpandEntries?): object
Return requested data as object if the data has already been loaded and stored in the model.
Parameters:
stringsPathA string containing the path to the data object that should be returned.
objectoContext?the optional context which is used with the sPath to retrieve the requested data.
booleanbIncludeExpandEntries?, Default: This parameter should be set when a URI or custom parameter with a $expand System Query Option was used to retrieve associated entries embedded/inline. If true then the getProperty function returns a desired property value/entry and includes the associated expand entries (if any). If false the associated/expanded entry properties are removed and not included in the desired entry as properties at all. This is useful for performing updates on the base entry only. Note: A copy and not a reference of the entry will be returned.
Returns:
objectoData Object containing the requested data if the path is valid.
Deprecated API:
please use getProperty instead
isCountSupported(): boolean
Returns whether this model supports the $count on its collections This method is deprecated, please use getDefaultCountMode instead.
Returns:
boolean
Deprecated API:
true
setCountSupported(bCountSupported)
Sets whether this OData service supports $count on its collections. This method is deprecated, please use setDefaultCountMode instead.
Parameters:
booleanbCountSupported
Deprecated API:
true