Show TOC

OData namespaceLocate this document in the navigation structure

Provides the ability to offline OData services.



            


The plugin provides the client with the ability to define offline stores for an OData producer.  When an offline store is first opened, it will synchronize with the OData producer.  OData requests made against this plugin will use the available open offline stores.  


            


            Requirements
            


            


The plugin requires that the datajs JavaScript library is included and available to the application.  If SAPUI5/OpenUI5 is used, you can call the method `jQuery.sap.require("sap.ui.thirdparty.datajs");` otherwise use a script include for the datajs library.


            


            Custom OData httpclient
            


            


A custom datajs OData httpclient is provided by the plugin.  This httpclient will resolve requests with the plugin if the service root of the request matches one of the open stores.  The httpclient will fallback to using the original OData.defaultHttpClient if the requests service root does not match any of the currently open stores.


            


            Flushing Modifications
            


            


The developer must explicitly call the flush method of a store to send modification to the OData producer.


            Refreshing Data
            


            


The developer must explicitly refresh their stores to get changes from the OData producer.  The plugin provides a refresh method that can refresh the whole store or a subset of it.
Example
Sample offline setup code
        var properties = {

            "name": "travel",

            "host": "smpserver",

            "port": 8080,

            "serviceRoot" : "connection_name",

            "definingRequests" : {

                "req1" : "/Travelagency"

            },

        }

        

        // Create the store.  Need to be online the first time this is created.

        var store = sap.OData.createOfflineStore(properties);

        store.open(function() {

            sap.OData.applyHttpClient();

            // Offline OData calls can now be made against datajs.

        }, function(e) {

            alert("Failed to open store!");

        });
Members
Name Description
stores An array of the currently open stores.
Type Definitions
Name Description
requestError( error ) Request error callback.
requestSuccess( response, response.statusCode, response.statusText, response.headers, response.body ) Request success callback that provides the response data.