cpryce
16 Oct 2007, 1:43 PM
I have a problem with JSONReader.
I have the following code:
eivia.data.FsRoots = function() {
this.store = null;
};
eivia.data.FsRoots.prototype = {
init: function(){
this._initialized = true;
var fsStoreProxy = new Ext.data.HttpProxy({
url: '/cgi-bin/eweb/getfsroots.cgi' ,
method: 'post'
});
var fsStoreReader = new Ext.data.JsonReader(
{ root: 'filesystem_roots' },
[
{name: 'name', mapping: 'name'},
{name: 'isPrivate', type: 'boolean', mapping: 'isPrivate'},
]
);
var fsRootsStore = new Ext.data.Store({
reader: fsStoreReader,
proxy: fsStoreProxy,
remoteSort: true
});
fsRootsStore.on("loadexception", this.loadExceptionHandler, this);
fsRootsStore.load();
this.store = fsRootsStore;
var first = this.store.getAt(0);
var last = this.store.getAt(1);
},
loadExceptionHandler: function(proxy, reader, resp){
if ( resp.status == '200' ) { return ; }
var text = resp.responseText;
text = text.replace(/[\s\S]*<body>/gi, "");
text = text.replace(/<\/body>[\s\S]*/gi, "");
alert(text);
}
};
Ext.onReady( function() {
eivia.data.fsroots = new eivia.data.FsRoots();
eivia.data.fsroots.init();
});
It is designed to consume some JSON that looks like this:
{"filesystem_roots":[
{"isPrivate":true,"name":"Private"},
{"isPrivate":false,"name":"Shared"}
]}
According to Firebug, the JSON is delivered, but the test variables at the end of the function, first and last, are undefined. When I examine the Store object in FireBug its data property is empty.
What could I be doing wrong?
I have the following code:
eivia.data.FsRoots = function() {
this.store = null;
};
eivia.data.FsRoots.prototype = {
init: function(){
this._initialized = true;
var fsStoreProxy = new Ext.data.HttpProxy({
url: '/cgi-bin/eweb/getfsroots.cgi' ,
method: 'post'
});
var fsStoreReader = new Ext.data.JsonReader(
{ root: 'filesystem_roots' },
[
{name: 'name', mapping: 'name'},
{name: 'isPrivate', type: 'boolean', mapping: 'isPrivate'},
]
);
var fsRootsStore = new Ext.data.Store({
reader: fsStoreReader,
proxy: fsStoreProxy,
remoteSort: true
});
fsRootsStore.on("loadexception", this.loadExceptionHandler, this);
fsRootsStore.load();
this.store = fsRootsStore;
var first = this.store.getAt(0);
var last = this.store.getAt(1);
},
loadExceptionHandler: function(proxy, reader, resp){
if ( resp.status == '200' ) { return ; }
var text = resp.responseText;
text = text.replace(/[\s\S]*<body>/gi, "");
text = text.replace(/<\/body>[\s\S]*/gi, "");
alert(text);
}
};
Ext.onReady( function() {
eivia.data.fsroots = new eivia.data.FsRoots();
eivia.data.fsroots.init();
});
It is designed to consume some JSON that looks like this:
{"filesystem_roots":[
{"isPrivate":true,"name":"Private"},
{"isPrivate":false,"name":"Shared"}
]}
According to Firebug, the JSON is delivered, but the test variables at the end of the function, first and last, are undefined. When I examine the Store object in FireBug its data property is empty.
What could I be doing wrong?