PDA

View Full Version : possible bug in Ext.data.loadRecords?



rmitchell62@me.com
13 Jan 2011, 8:51 PM
Can anyone help me understand this? I'm pretty new to Sencha Touch - this is my second HttpRequest. First one used Ext.Ajax.request and worked very well. Very easy once I found an example. The server just returned html which I stuffed into a container.

Now I'm trying to used the Store/Model/Proxy/Reader -json route for a second api call.
I did this:


function getSizeColour(){


relatedSku = Ext.getCmp('fSCSearchFld').getValue();
var gSC_store = new Ext.data.Store({
model: 'getSC',
proxy: {
type: 'ajax',
url: '/dynamic/getSizeColour.cgi',
extraParams: {
SKU: relatedSku, //'SKU I know, send back colour/size permutations',
UUID: gSC_sessionUuid, // 'a uuid or null',
},
reader: {
type: 'json',
root: 'sizeByColour',
successProperty: 'success',
totalProperty: 'uuid' //note totalProperty is overloaded
}
}
});
gSC_store.load();
}

I run the code, and watch in the chrome debugger, tracing the httprequests. This gets emitted:


XHR finished loading: "http://192.168.10.19/dynamic/getSizeColour.cgi?_dc=1294977242083&SKU=12345&UUID=&limit=25".

So far so good. My proxy rewrites /dynamic to /cgi-bin and passes the request to another host. The parameters look as expected. (although you stick a magic 'limit' in there????)

However I haven't written the cgi-bin perl script on the server yet so, as expected I get an error from the far end.
Response in the debugger is:


Failed to load resource: the server responded with a status of 404 (Not Found)
getSizeColour.cgiFailed to load resource: the server responded with a status of 404 (Not Found)
XHR finished loading: "http://192.168.10.19/dynamic/getSizeColour.cgi?_dc=1294977242083&SKU=12345&UUID=&limit=25".
sencha-touch-debug.js:7209Uncaught TypeError: Cannot read property 'length' of undefined
Ext.data.Store.Ext.extend.loadRecordssencha-touch-debug.js:7209
Ext.data.Store.Ext.extend.onProxyLoadsencha-touch-debug.js:7021
(anonymous function)sencha-touch-debug.js:8726
Ext.data.Connection.Ext.extend.onCompletesencha-touch-debug.js:17495
Ext.data.Connection.Ext.extend.onStateChangesencha-touch-debug.js:17442
(anonymous function)sencha-touch-debug.js:3421

Looking at:
sencha-touch-debug.js:7209Uncaught TypeError: Cannot read property 'length' of undefined




7201 loadRecords: function(records, add) {
7202 if (!add) {
7203 this.data.clear();
7204 }
7205
7206 this.data.addAll(records);
7207
7208
7209
for (var i = 0, length = records.length; i < length; i++) {
sencha-touch-debug.js:7209Uncaught TypeError: Cannot read property 'length' of undefined
7210 records[i].needsAdd = false;
7211 records[i].join(this);
7212 }
7213



Question:
1) Shouldn't the library see that the server couldn't deliver the document?
2) How can I perform error checking on server return codes using Store/Proxy?
3) Any problem overloading the 'totalProperty' for a sessionUuid or will this be modified from what the server sends?

Comments
1) I really like the pipelining that you are attempting with Panel/DataView/Store/Model/Proxy/Reader/ Is there a clearly worked meaningful example? For instance the examples I've seen don't seem to pass 'query' parameters to the server before getting data - but you define filters and sorters. Is there an overall architecture document that describes your view of data interchange? Are these request parameters 'standards'? Where described? Or is this intended to interoperate (only) with Ext GWT for instance?

Really loving what I see.
Rob