Changeset 1264
- Timestamp:
- 10/31/08 11:10:37 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/list-tests.html
r1263 r1264 16 16 <li>widgets/data/test_LayerStoreMediator.html</li> 17 17 <li>widgets/data/test_GridRowFeatureMediator.html</li> 18 <li>widgets/data/Proxy.html</li> 18 19 <li>widgets/toolbar/Toolbar.html</li> 19 20 </ul> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/Proxy.js
r1149 r1264 36 36 37 37 Ext.extend(mapfish.widgets.data.Proxy, Ext.data.DataProxy, { 38 /** 39 * APIProperty: protocol 40 * {<OpenLayers.Protocol>} The protocol used to fetch features. 41 */ 42 protocol: null, 38 43 39 44 /** 40 * Property: loadArgs 41 * {Object} Arguments passed to the load method 45 * APIProperty: abortPrevious 46 * {Boolean} Whether to abort the previous request or not, defaults 47 * to true. 42 48 */ 43 loadArgs: null,49 abortPrevious: true, 44 50 45 51 /** 46 * APIMethod: load 52 * Property: response 53 * {<OpenLayers.Protocol.Response>} The response returned by 54 * the read call on the protocol. 55 */ 56 response: null, 57 58 /** 59 * Method: load 47 60 * 48 61 * Parameters: 49 * params - {Object} An object containing properties which are to be used as HTTP parameters50 * for the request to the remote server.62 * params - {Object} An object containing properties which are to be used 63 * as HTTP parameters for the request to the remote server. 51 64 * reader - {Ext.data.DataReader} The Reader object which converts the data 52 65 * object into a block of Ext.data.Records. 53 * callback - {Function} The function into which to pass the block of Ext.data.Records. 54 * The function must be passed: 55 * - The Record block object 56 * - The "arg" argument from the load function 57 * - A boolean success indicator 66 * callback - {Function} The function into which to pass the block of 67 * Ext.data.Records. The function is passed the Record block object, 68 * the "args" argument passed to the load function, and a boolean 69 * success indicator 58 70 * scope - {Object} The scope in which to call the callback 59 * arg - {Object} An optional argument which is passed to the callback as its second parameter. 71 * arg - {Object} An optional argument which is passed to the callback 72 * as its second parameter. 60 73 */ 61 74 load: function(params, reader, callback, scope, arg) { 62 75 if (this.fireEvent("beforeload", this, params) !== false) { 63 64 this.loadArgs = { 76 var o = { 65 77 params: params || {}, 66 78 request: { … … 71 83 reader: reader 72 84 }; 73 74 this.protocol.read({ 75 filter: params, 76 callback: this.loadResponse, 85 var cb = OpenLayers.Function.bind(this.loadResponse, this, o); 86 if (this.abortPrevious) { 87 this.abortRequest(); 88 } 89 this.response = this.protocol.read({ 90 params: params, 91 filter: arg.filter, 92 callback: cb, 77 93 scope: this 78 94 }); … … 83 99 84 100 /** 101 * Method: abortRequest 102 * Called to abort any ongoing request. 103 */ 104 abortRequest: function() { 105 // FIXME really we should rely on the protocol itself to 106 // cancel the request, the Protocol class in OpenLayers 107 // 2.7 does not expose a cancel() method 108 if (this.response) { 109 var response = this.response; 110 if (response.priv && 111 typeof response.priv.abort == "function") { 112 response.priv.abort(); 113 this.response = null; 114 } 115 } 116 }, 117 118 /** 85 119 * Method: loadResponse 86 120 * Handle response from the protocol 87 121 * 88 122 * Parameters: 123 * o - {Object} 89 124 * response - {<OpenLayers.Protocol.Response>} 90 125 */ 91 loadResponse: function( response) {126 loadResponse: function(o, response) { 92 127 if (response.success()) { 93 var result = this.loadArgs.reader.read(response); 94 this.fireEvent("load", this, this.loadArgs, this.loadArgs.request.arg); 95 96 this.loadArgs.request.callback.call(this.loadArgs.request.scope, result, 97 this.loadArgs.request.arg, true); 128 var result = o.reader.read(response); 129 this.fireEvent("load", this, o, o.request.arg); 130 o.request.callback.call( 131 o.request.scope, result, o.request.arg, true); 98 132 } else { 99 this.fireEvent("loadexception", this, this.loadArgs, response);100 this.loadArgs.request.callback.call(this.loadArgs.request.scope, null,101 this.loadArgs.request.arg, false);133 this.fireEvent("loadexception", this, o, response); 134 o.request.callback.call( 135 o.request.scope, null, o.request.arg, false); 102 136 } 103 137 }