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
251 251 } 252 252 }, 253 253 { 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 { 254 280 name: "Identity API: fetchItemByIdentity() notFound", 255 281 runTest: function(datastore, t){ 256 282 // summary: … … 475 501 } 476 502 }, 477 503 { 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 { 478 530 name: "Read API: fetch() one", 479 531 runTest: function(datastore, t){ 480 532 // summary: -
data/ItemFileReadStore.js
61 61 this._reverseRefMap = "_RRM"; // Default attribute for constructing a reverse reference map for use with reference integrity 62 62 this._loadInProgress = false; //Got to track the initial load to prevent duelling loads of the dataset. 63 63 this._queuedFetches = []; 64 if(keywordParameters.urlPreventCache !== undefined){ 65 this.urlPreventCache = keywordParameters.urlPreventCache?true:false; 66 } 64 67 }, 65 68 66 69 url: "", // use "" rather than undefined for the benefit of the parser (#3539) 67 70 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 68 76 _assertIsItem: function(/* item */ item){ 69 77 // summary: 70 78 // This function tests whether the item passed in is indeed an item in the store. … … 284 292 this._loadInProgress = true; 285 293 var getArgs = { 286 294 url: self._jsonFileUrl, 287 handleAs: "json-comment-optional" 295 handleAs: "json-comment-optional", 296 preventCache: this.urlPreventCache 288 297 }; 289 298 var getHandler = dojo.xhrGet(getArgs); 290 299 getHandler.addCallback(function(data){ … … 636 645 this._loadInProgress = true; 637 646 var getArgs = { 638 647 url: self._jsonFileUrl, 639 handleAs: "json-comment-optional" 648 handleAs: "json-comment-optional", 649 preventCache: this.urlPreventCache 640 650 }; 641 651 var getHandler = dojo.xhrGet(getArgs); 642 652 getHandler.addCallback(function(data){ … … 727 737 var getArgs = { 728 738 url: self._jsonFileUrl, 729 739 handleAs: "json-comment-optional", 740 preventCache: this.urlPreventCache, 730 741 sync: true 731 742 }; 732 743 var getHandler = dojo.xhrGet(getArgs);