Ticket #6072: dojo.data.ItemFileStore_20080410.patch

File dojo.data.ItemFileStore_20080410.patch, 4.0 kB (added by jaredj, 9 months ago)
  • tests/data/readOnlyItemFileTestTemplates.js

     
    251251                } 
    252252        }, 
    253253        { 
     254                name: "Identity API: fetchItemByIdentity() preventCache", 
     255                runTest: function(datastore, t){ 
     256                        //      summary:  
     257                        //              Simple test of the fetchItemByIdentity function of the store. 
     258                        var args = tests.data.readOnlyItemFileTestTemplates.getTestData("countries"); 
     259                        args.urlPreventCache = true; 
     260                        var store = new datastore(args); 
     261 
     262                        var d = new doh.Deferred(); 
     263                        function onItem(item){ 
     264                                t.assertTrue(item !== null); 
     265                                if(item !== null){ 
     266                                        var name = store.getValue(item,"name"); 
     267                                        t.assertEqual(name, "El Salvador"); 
     268                                } 
     269                                d.callback(true); 
     270                        } 
     271                        function onError(errData){ 
     272                                t.assertTrue(false); 
     273                                d.errback(errData); 
     274                        } 
     275                        store.fetchItemByIdentity({identity: "sv", onItem: onItem, onError: onError}); 
     276                        return d; // Deferred 
     277                } 
     278        }, 
     279        { 
    254280                name: "Identity API: fetchItemByIdentity() notFound", 
    255281                runTest: function(datastore, t){ 
    256282                        //      summary:  
     
    475501                } 
    476502        }, 
    477503        { 
     504                name: "Read API: fetch() all PreventCache", 
     505                runTest: function(datastore, t){ 
     506                        //      summary:  
     507                        //              Simple test of a basic fetch on ItemFileReadStore. 
     508                        //      description: 
     509                        //              Simple test of a basic fetch on ItemFileReadStore. 
     510                        var args = tests.data.readOnlyItemFileTestTemplates.getTestData("countries"); 
     511                        args.urlPreventCache = true; 
     512                        var store = new datastore(args); 
     513                         
     514                        var d = new doh.Deferred(); 
     515                        function completedAll(items, request){ 
     516                                t.is(7, items.length); 
     517                                d.callback(true); 
     518                        } 
     519                        function error(errData, request){ 
     520                                t.assertTrue(false); 
     521                                d.errback(errData); 
     522                        } 
     523 
     524                        //Get everything... 
     525                        store.fetch({ onComplete: completedAll, onError: error}); 
     526                        return d; 
     527                } 
     528        }, 
     529        { 
    478530                name: "Read API: fetch() one", 
    479531                runTest: function(datastore, t){ 
    480532                        //      summary:  
  • data/ItemFileReadStore.js

     
    6161                this._reverseRefMap = "_RRM"; // Default attribute for constructing a reverse reference map for use with reference integrity 
    6262                this._loadInProgress = false;   //Got to track the initial load to prevent duelling loads of the dataset. 
    6363                this._queuedFetches = []; 
     64                if(keywordParameters.urlPreventCache !== undefined){ 
     65                        this.urlPreventCache = keywordParameters.urlPreventCache?true:false; 
     66                } 
    6467        }, 
    6568         
    6669        url: "",        // use "" rather than undefined for the benefit of the parser (#3539) 
    6770 
     71        //Parameter to allow specifying if preventCache should be passed to the xhrGet call or not when loading data from a url.   
     72        //Note this does not mean the store calls the server on each fetch, only that the data load has preventCache set as an option. 
     73        //Added for tracker: #6072 
     74        urlPreventCache: false,   
     75 
    6876        _assertIsItem: function(/* item */ item){ 
    6977                //      summary: 
    7078                //              This function tests whether the item passed in is indeed an item in the store. 
     
    284292                                        this._loadInProgress = true; 
    285293                                        var getArgs = { 
    286294                                                        url: self._jsonFileUrl,  
    287                                                         handleAs: "json-comment-optional" 
     295                                                        handleAs: "json-comment-optional", 
     296                                                        preventCache: this.urlPreventCache 
    288297                                                }; 
    289298                                        var getHandler = dojo.xhrGet(getArgs); 
    290299                                        getHandler.addCallback(function(data){ 
     
    636645                                        this._loadInProgress = true; 
    637646                                        var getArgs = { 
    638647                                                        url: self._jsonFileUrl,  
    639                                                         handleAs: "json-comment-optional" 
     648                                                        handleAs: "json-comment-optional", 
     649                                                        preventCache: this.urlPreventCache 
    640650                                        }; 
    641651                                        var getHandler = dojo.xhrGet(getArgs); 
    642652                                        getHandler.addCallback(function(data){ 
     
    727737                                var getArgs = { 
    728738                                        url: self._jsonFileUrl,  
    729739                                        handleAs: "json-comment-optional", 
     740                                        preventCache: this.urlPreventCache, 
    730741                                        sync: true 
    731742                                }; 
    732743                        var getHandler = dojo.xhrGet(getArgs);