sap.ui.model.odata.v2.ODataModel.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.odata.v2.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:
{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 |
Returns a metadata object for class sap.ui.model.odata.v2.ODataModel.
Returns:
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|sting[]} | vUrl | Either one URL as string or an array or URL strings |
Returns:
{Promise} | The 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:
{string} | sXMLContent | The string that should be parsed as annotation XML |
{boolean} | bSuppressEvents? | Whether not to fire annotationsLoaded event on the annotationParser |
Returns:
{Promise} | The Promise to parse the given XML-String, resolved if parsed without errors, rejected if errors occur |
Attach event-handler fnFunction
to the 'annotationsFailed' event of this sap.ui.model.odata.v2.ODataModel
.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, the global context (window) is used. |
Returns:
Attach event-handler
fnFunction
to the 'annotationsLoaded' event of this
sap.ui.model.odata.v2.ODataModel
.
Experimental API:The API is NOT stable yet. Use at your own risk.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, the global context (window) is used. |
- Experimental:
- The API is NOT stable yet. Use at your own risk.
Returns:
Attach event-handler fnFunction
to the 'batchRequestCompleted' event of this sap.ui.model.odata.v2.ODataModel
.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, the global context (window) is used. |
Returns:
Attach event-handler fnFunction
to the 'batchRequestFailed' event of this sap.ui.model.odata.v2.ODataModel
.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this Model is used. |
Returns:
Attach event-handler fnFunction
to the 'requestSent' event of this sap.ui.model.odata.v2.ODataModel
.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, the global context (window) is used. |
Returns:
Attach event-handler fnFunction
to the 'metadataFailed' event of this sap.ui.model.odata.v2.ODataModel
.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, the global context (window) is used. |
Returns:
Attach event-handler fnFunction
to the 'metadataLoaded' event of this sap.ui.model.odata.v2.ODataModel
.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, the global context (window) is used. |
Returns:
callFunction(sFunctionName, mParameters?): object
Trigger a request to the function import odata service that was specified in the model constructor.
If the ReturnType of the function import is either an EntityType or a collection of EntityType the changes are reflected in the model, otherwise they are ignored, and the response
can be processed in the successHandler.
Parameters:
{string} | sFunctionName | A string containing the name of the function to call. The name is concatenated to the sServiceUrl which was specified in the model constructor. |
{map} | mParameters? | Optional parameter map containing any of the following properties: |
{string} | mParameters.method? | A string containing the type of method to call this function with |
{map} | mParameters.urlParameters? | A map containing the parameters that will be passed as query strings |
{function} | mParameters.success? | a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response . |
{function} | mParameters.error? | a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information. |
{string} | mParameters.batchGroupId? | Deprecated - use groupId instead |
{string} | mParameters.groupId? | groupId for this request. Requests belonging to the same groupId will be bundled in one batch request. |
{string} | mParameters.eTag? | If the functionImport changes an entity, the eTag for this entity could be passed with this parameter |
{string} | mParameters.changeSetId? | changeSetId for this request |
Returns:
{object} | oRequestHandle An object which has an abort function to abort the current request. |
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:
{string} | sPath | A 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. |
{object} | oData | data of the entry that should be created. |
{map} | mParameters? | Optional parameter map containing any of the following properties: |
{object} | mParameters.context? | If specified the sPath has to be relative to the path given with the context. |
{function} | mParameters.success? | a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response. |
{function} | mParameters.error? | a callback function which is called when the request failed. The handler can have the parameter oError which contains additional error information. |
{map} | mParameters.urlParameters? | A map containing the parameters that will be passed as query strings |
{map} | mParameters.headers? | A map of headers for this request |
{string} | mParameters.batchGroupId? | Deprecated - use groupId instead |
{string} | mParameters.groupId? | groupId for this request. Requests belonging to the same groupId will be bundled in one batch request. |
{string} | mParameters.changeSetId? | changeSetId for this request |
Returns:
{object} | an object which has an abort function to abort the current request. |
createBindingContext(sPath, oContext?, mParameters?, fnCallBack?, bReload?)
Creates a binding context for the given path If the data of the context is not yet available, it can not be created, but first the entity needs to be fetched from the server asynchronously. In case no callback function is provided, the request will not be triggered.
Parameters:
{string} | sPath | binding path |
{object} | oContext? | bindingContext |
{map} | mParameters? | a map which contains additional parameters for the binding |
{string} | mParameters.expand? | Standing for OData $expand query option which should be included in the request |
{string} | mParameters.select? | Standing for OData $select query option parameter which should be included in the request |
{map} | mParameters.custom? | an optional map of custom query parameters. Custom parameters must not start with $ . |
{function} | fnCallBack? | function called when context is created |
{boolean} | bReload? | reload of data |
See:
sap.ui.model.Model.prototype.createBindingContext |
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 properties parameter can be used as follows:
- properties 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. - properties could be an object which includes the desired properties and the values which should be used for the created entry.
If properties 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:
{String} | sPath | Name of the path to the EntitySet |
{map} | mParameters | A map of the following parameters: |
{array|object} | mParameters.properties? | An array that specifies a set of properties or the entry |
{string} | mParameters.batchGroupId? | Deprecated - use groupId instead |
{string} | mParameters.groupId? | The groupId. Requests belonging to the same groupId will be bundled in one batch request. |
{string} | mParameters.changeSetId? | The changeSetId |
{sap.ui.model.Context} | mParameters.context? | The binding context |
{function} | mParameters.success? | The success callback function |
{function} | mParameters.error? | The error callback function |
{map} | mParameters.headers? | A map of headers |
{map} | mParameters.urlParameters? | A map of url parameters |
Returns:
createKey(sCollection, oKeyProperties): string
Creates the key from the given collection name and property map. Please make sure that the metadata document is loaded before using this function.
Parameters:
{string} | sCollection | The name of the collection |
{object} | oKeyProperties | The object containing at least all the key properties of the entity type |
Returns:
{string} | [sKey] key of the entry |
deleteCreatedEntry(oContext)
Deletes a created entry from the request queue and the model.
Parameters:
destroy()
See:
sap.ui.model.Model.prototype.destroy |
Detach event-handler
fnFunction
from the 'annotationsFailed' event of this
sap.ui.model.odata.v2.ODataModel
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Detach event-handler
fnFunction
from the 'annotationsLoaded' event of this
sap.ui.model.odata.v2.ODataModel
.
Experimental API:The API is NOT stable yet. Use at your own risk.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
- Experimental:
- The API is NOT stable yet. Use at your own risk.
Returns:
Detach event-handler
fnFunction
from the 'batchRequestCompleted' event of this
sap.ui.model.odata.v2.ODataModel
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Detach event-handler
fnFunction
from the 'batchRequestFailed' event of this
sap.ui.model.odata.v2.ODataModel
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Detach event-handler
fnFunction
from the 'batchRequestSent' event of this
sap.ui.model.odata.v2.ODataModel
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Detach event-handler
fnFunction
from the 'metadataFailed' event of this
sap.ui.model.odata.v2.ODataModel
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Detach event-handler
fnFunction
from the 'metadataLoaded' event of this
sap.ui.model.odata.v2.ODataModel
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Fire event annotationsFailed to attached listeners.
Parameters:
{object} | mArguments? | the arguments to pass along with the event. |
{string} | mArguments.message? | A text that describes the failure. |
{string} | mArguments.statusCode? | HTTP status code returned by the request (if available) |
{string} | mArguments.statusText? | The status as a text, details not specified, intended only for diagnosis output |
{string} | mArguments.responseText? | Response that has been received for the request ,as a text string |
Returns:
Fire event annotationsLoaded to attached listeners.
Parameters:
Returns:
Fire event batchRequestCompleted to attached listeners.
Parameters:
{object} | mArguments | parameters to add to the fired event |
{string} | mArguments.ID | The request ID |
{string} | mArguments.url | The url which is sent to the backend |
{string} | mArguments.method | The HTTP method |
{map} | mArguments.headers | The request headers |
{boolean} | mArguments.success | Request was successful or not |
{boolean} | mArguments.async | If the request is synchronous or asynchronous (if available) |
{array} | mArguments.requests | Array of embedded requests ($batch) - empty array for non batch requests. Each request object within the array contains the following properties: url, method, headers, response object |
{object} | mArguments.response | The response object - empty object if no response: The response object contains the following properties: message, success, headers, statusCode, statusText, responseText |
Returns:
Fire event batchRequestFailed to attached listeners.
Parameters:
{object} | mArguments | the arguments to pass along with the event. |
{string} | mArguments.ID | The request ID |
{string} | mArguments.url | The url which is sent to the backend |
{string} | mArguments.method | The HTTP method |
{map} | mArguments.headers | The request headers |
{boolean} | mArguments.async | If the request is synchronous or asynchronous (if available) |
{boolean} | mArguments.success | Request was successful or not |
{object} | mArguments.response | The response object - empty object if no response The response object contains the following properties: message, success, headers, statusCode, statusText, responseText |
{array} | mArguments.requests | Array of embedded requests ($batch) Each request object within the array contains the following properties: url, method, headers, response object |
Returns:
Fire event batchRequestSent to attached listeners.
Parameters:
{object} | mArguments? | the arguments to pass along with the event. |
{string} | mArguments.url? | The url which is sent to the backend. |
{string} | mArguments.type? | The type of the request (if available) |
{boolean} | mArguments.async? | If the request is synchronous or asynchronous (if available) |
{array} | mArguments.requests | Array of embedded requests ($batch) Each request object within the array contains the following properties: url, method, headers |
Returns:
Fire event metadataFailed to attached listeners.
Parameters:
{object} | mArguments? | the arguments to pass along with the event. |
{string} | mArguments.message? | A text that describes the failure. |
{string} | mArguments.statusCode? | HTTP status code returned by the request (if available) |
{string} | mArguments.statusText? | The status as a text, details not specified, intended only for diagnosis output |
{string} | mArguments.responseText? | Response that has been received for the request ,as a text string |
Returns:
Fire event metadataLoaded to attached listeners.
Parameters:
Returns:
forceEntityUpdate(sKey)
Force the update on the server of an entity by setting its ETag to '*'. ETag handling must be active so the force update will work.
Parameters:
{string} | sKey | The key to an Entity e.g.: Customer(4711) |
getChangeGroups(): map
Returns the definition of groups per EntityType for TwoWay changes
Returns:
{map} | mChangeGroups Definition of Groups for "TwoWay" changes |
Returns the default count mode for retrieving the count of collections
- Since:
- 1.20
Returns:
getDeferredGroups(): array
Returns the array of GroupIds that are set as deferred
Returns:
{array} | aGroupIds The array of deferred GroupIds |
getETag(sPath?, oContext?, oEntity?): string
Returns the ETag for a given binding path/context or data object
Parameters:
{string} | sPath? | The binding path |
{sap.ui.model.Context} | oContext? | The binding context |
{object} | oEntity? | The entity data |
Returns:
{string} | The found ETag (or null if none could be found) |
getHeaders(): object
Returns all headers and custom headers which are stored in the OData model.
Returns:
getKey(vValue): string
Returns the key part from the entry URI or the given context or object
Parameters:
{string|object|sap.ui.model.Context} | vValue | A string representation of an URI, the context or entry object |
Returns:
{string} | [sKey] key of the entry |
Returns an instance of an OData meta model which offers a unified access to both OData V2 meta data 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.v2.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:
getOriginalProperty(sPath, oContext?): any
Returns the original value for the property with the given path and context. The original value is the value that was last responded by the server.
Parameters:
{string} | sPath | the path/name of the property |
{object} | oContext? | the context if available to access the property value |
Returns:
{any} | vValue the value of the property |
getProperty(sPath, oContext?, bIncludeExpandEntries?): any
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:
{string} | sPath | the path/name of the property |
{object} | oContext? | the context if available to access the property value |
{boolean} | bIncludeExpandEntries? | 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:
{any} | vValue the value of the property |
getSecurityToken(): string
Returns the current security token. If the token has not been requested from the server it will be requested first.
Returns:
{string} | the CSRF security token |
getServiceAnnotations
(): Object Return the annotation object. Please note that the metadata is loaded asynchronously and 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.
Experimental API:This feature has not been tested due to the lack of OData testing infrastructure. The API is NOT stable yet. Use at your own risk.
- Experimental:
- This feature has not been tested due to the lack of OData testing infrastructure. The API is NOT stable yet. Use at your own risk.
Returns:
Return the parsed XML metadata as a Javascript object. Please note that the metadata is loaded asynchronously and 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:
hasPendingChanges(): boolean
Checks if there exist pending changes in the model created by the setProperty method.
Returns:
hasPendingRequests(): boolean
Checks if there are pending requests, either ongoing or sequential
Returns:
isMetadataLoadingFailed(): boolean
Checks whether metadata loading has failed in the past.
- Since:
- 1.38
Returns:
{boolean} | returns whether metadata request has failed |
metadataLoaded(): Promise
Returns a promise for the loaded state of the metadata. The promise won't get rejected in case the metadata loading failed but is only resolved if the metadata is loaded successfully. If refreshMetadata
function is called after this promise is already resolved you should rely on the promise returned by refreshMetadata
to get information about the refreshed metadata loaded state.
- Since:
- 1.30
Returns:
{Promise} | returns a promise on metadata loaded state |
read(sPath, mParameters?): object
Trigger a GET request to the odata service that was specified in the model constructor. The data will be stored in the model. The requested data is returned with the response.
Parameters:
{string} | sPath | A 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. |
{map} | mParameters? | Optional parameter map containing any of the following properties: |
{object} | mParameters.context? | If specified the sPath has to be is relative to the path given with the context. |
{map} | mParameters.urlParameters? | A map containing the parameters that will be passed as query strings |
{array} | mParameters.filters? | an array of sap.ui.model.Filter to be included in the request URL |
{array} | mParameters.sorters? | an array of sap.ui.model.Sorter to be included in the request URL |
{function} | mParameters.success? | a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response. |
{function} | mParameters.error? | a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information. |
{string} | mParameters.batchGroupId? | Deprecated - use groupId instead |
{string} | mParameters.groupId? | groupId for this request. Requests belonging to the same groupId will be bundled in one batch request. |
Returns:
{object} | an object which has an abort function to abort the current request. |
refresh(bForceUpdate?, bRemoveData?, sGroupId?)
Refresh the model. This will check all bindings for updated data and update the controls if data has been changed.
Parameters:
{boolean} | bForceUpdate? | Force update of controls |
{boolean} | bRemoveData? | If 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. |
{string} | sGroupId? | The groupId. Requests belonging to the same groupId will be bundled in one batch request. |
refreshMetadata(): Promise
Refreshes the metadata for model, e.g. in case the request for metadata has failed. Returns a new promise which can be resolved or rejected depending on the metadata loading state.
Returns:
{Promise} | returns a promise on metadata loaded state or null if metadata is not initialized or currently refreshed. |
refreshSecurityToken(fnSuccess?, fnError?): object
refresh XSRF token by performing a GET request against the service root URL.
Parameters:
{function} | fnSuccess? | a callback function which is called when the data has been successfully retrieved. |
{function} | fnError? | a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information. |
Returns:
{object} | an 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:
{string} | sPath | A 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. |
{object} | mParameters? | Optional, can contain the following attributes: |
{object} | mParameters.context? | If specified the sPath has to be relative to the path given with the context. |
{function} | mParameters.success? | a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response . |
{function} | mParameters.error? | a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information. |
{string} | mParameters.eTag? | If specified, the If-Match-Header will be set to this Etag. |
{map} | mParameters.urlParameters? | A map containing the parameters that will be passed as query strings |
{string} | mParameters.batchGroupId? | Deprecated - use groupId instead |
{string} | mParameters.groupId? | groupId for this request. Requests belonging to the same groupId will be bundled in one batch request. |
{string} | mParameters.changeSetId? | changeSetId for this request |
Returns:
{object} | an object which has an abort function to abort the current request. |
resetChanges(aPath?)
Resets the collected changes by the setProperty method.
Parameters:
{array} | aPath? | Array of paths that should be resetted. If no array is passed all changes will be resetted. |
securityTokenAvailable(): Promise
Returns a promise, which will resolve with the security token as soon as it is available
Returns:
{Promise} | the CSRF security token |
setChangeGroups(mGroups)
Definition of groups per EntityType for "TwoWay" changes
Parameters:
{map} | mGroups | A map containing the definition of bacthGroups for TwoWay changes. The Map has the following format: { "EntityTypeName": { groupId: "ID", [changeSetId: "ID",] [single: true/false,] } } GroupId: Defines the Group for changes of the defined EntityTypeName changeSetId: Defines a changeSetId wich bundles the changes for the EntityType. single: Defines if every change will get an own changeSet (true) |
setDefaultCountMode(sCountMode)
Sets the default way to retrieve the count of collections in this model. Count can be determined either by sending a separate $count request, including $inlinecount=allpages in data requests, both of them or not at all.
Parameters:
- Since:
- 1.20
setDeferredGroups(aGroupIds)
Setting request groups as deferred. Requests that belongs to a deferred group will be sent manually via a submitChanges call.
Parameters:
{array} | aGroupIds | Array of GroupIds that should be set as deferred |
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:
{object} | mHeaders | the header name/value map. |
setProperty(sPath, oValue, oContext?, bAsyncUpdate?): boolean
Sets a new value for the given property
sPropertyName
in the model.
If the changeBatchGroup for the changed EntityType is set to deferred changes could be submitted with submitChanges. Otherwise the change will be submitted directly.
Parameters:
{string} | sPath | path of the property to set |
{any} | oValue | value to set the property to |
{object} | oContext? | the context which will be used to set the property |
{boolean} | bAsyncUpdate? | whether to update other bindings dependent on this property asynchronously |
Returns:
{boolean} | true 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:
{boolean} | bRefreshAfterChange | Refresh after change |
- Since:
- 1.16.3
setTokenHandlingEnabled(bTokenHandling?)
Enable/Disable XCSRF-Token handling
Parameters:
{boolean} | bTokenHandling?, Default: true | whether to use token handling or not |
setUseBatch(bUseBatch?)
Parameters:
{boolean} | bUseBatch? | whether the requests should be encapsulated in a batch request |
submitChanges(mParameters?): object
Submits the collected changes which were collected by the setProperty method. The update method is defined by the global
defaultUpdateMethod
parameter which is sap.ui.model.odata.UpdateMethod.Merge by default. In case of a sap.ui.model.odata.UpdateMethod.Merge request only the changed properties will be updated. 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.
Important: The success/error handler will only be called if batch support is enabled. If multiple batchGroups are submitted the handlers will be called for every batchGroup.
Parameters:
{object} | mParameters? | a map which contains the following parameter properties: |
{string} | mParameters.batchGroupId? | Deprecated - use groupId instead |
{string} | mParameters.groupId? | defines the group that should be submitted. If not specified all deferred groups will be submitted. Requests belonging to the same groupId will be bundled in one batch request. |
{function} | mParameters.success? | a callback function which is called when the data has been successfully updated. The handler can have the following parameters: oData . oData contains the parsed response data as a Javascript object. The batch response is in the __batchResponses property which may contain further __changeResponses in an array depending on the amount of changes and changesets of the actual batch request which was sent to the backend. The changeResponses contain the actual response of that changeset in the response property. For each changeset there is also a __changeResponse property. |
{function} | mParameters.error? | a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information |
{string} | mParameters.eTag? | 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:
{object} | an object which has an abort function to abort the current request or requests |
update(sPath, oData, mParameters?): object
Trigger a PUT/MERGE request to the odata service that was specified in the model constructor. The update method used is defined by the global defaultUpdateMethod
parameter which is sap.ui.model.odata.UpdateMethod.Merge by default. Please note that deep updates are not supported and may not work. These should be done seperate on the entry directly.
Parameters:
{string} | sPath | A 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. |
{object} | oData | data of the entry that should be updated. |
{map} | mParameters? | Optional, can contain the following attributes: |
{object} | mParameters.context? | If specified the sPath has to be is relative to the path given with the context. |
{function} | mParameters.success? | a callback function which is called when the data has been successfully updated. |
{function} | mParameters.error? | a callback function which is called when the request failed. The handler can have the parameter oError which contains additional error information. |
{string} | mParameters.eTag? | If specified, the If-Match-Header will be set to this Etag. 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. |
{map} | mParameters.urlParameters? | A map containing the parameters that will be passed as query strings |
{map} | mParameters.headers? | A map of headers for this request |
{string} | mParameters.batchGroupId? | Deprecated - use groupId instead |
{string} | mParameters.groupId? | groupId for this request. Requests belonging to the same groupId will be bundled in one batch request. |
{string} | mParameters.changeSetId? | changeSetId for this request |
Returns:
{object} | an object which has an abort function to abort the current request. |
updateBindings(bForceUpdate?)
update all bindings
Parameters:
{boolean} | bForceUpdate? | If set to false an update will only be done when the value of a binding changed. |
getChangeBatchGroups(): map
Returns the definition of batchGroups per EntityType for TwoWay changes
- Deprecated:
- Since 1.36 use getChangeGroups instead
Returns:
{map} | mChangeBatchGroups Definition of bactchGRoups for "TwoWay" changes |
getData(sPath, oContext?, bIncludeExpandEntries?): object
Return requested data as object if the data has already been loaded and stored in the model.
Parameters:
{string} | sPath | A string containing the path to the data object that should be returned. |
{object} | oContext? | the optional context which is used with the sPath to retrieve the requested data. |
{boolean} | bIncludeExpandEntries? | 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. |
- Deprecated:
- please use getProperty instead
Returns:
{object} | oData Object containing the requested data if the path is valid. |
getDeferredBatchGroups(): array
Returns the array of batchGroupIds that are set as deferred
- Deprecated:
- Since 1.32 use getDeferredGroups instead
Returns:
{array} | aGroupIds The array of deferred batchGroupIds |
setChangeBatchGroups(mGroups)
Definition of batchGroups per EntityType for "TwoWay" changes
Parameters:
{map} | mGroups | A map containing the definition of bacthGroups for TwoWay changes. The Map has the following format: { "EntityTypeName": { batchGroupId: "ID", [changeSetId: "ID",] [single: true/false,] } } bacthGroupId: Defines the bacthGroup for changes of the defined EntityTypeName changeSetId: Defines a changeSetId wich bundles the changes for the EntityType. single: Defines if every change will get an own changeSet (true) |
- Deprecated:
- Since 1.32 use setChangesGroups instead
setDeferredBatchGroups(aGroupIds)
Setting batch groups as deferred. Requests that belongs to a deferred batch group will be sent manually via a submitChanges call.
Parameters:
{array} | aGroupIds | Array of batchGroupIds that should be set as deferred |
- Deprecated:
- Since 1.32 use setDeferredGroups instead