View Full Version : XMLReader Config

28 Apr 2008, 2:46 AM
I have a question on the config of a XMLReader.
When there is an error my XML is:

<?xml version="1.0" encoding="UTF-8" ?>

My XMLReader config is:

new Ext.data.XmlReader(
{record: 'Documento',id: documento_id,success:'success'},
[documento_id,'titolo', 'autore','tipo_id', {name:'created', type:'date',dateFormat: 'Y-m-d H:i:s'},'stato']

But I can't to recognize when success is false.
Instead where there isn't error all works fine.
Where is the error ?

28 Apr 2008, 3:57 AM
You'll have to use an explicit http://dev.extjs.com/deploy/dev/docs/?class=Ext.data.HttpProxy

with a loadexception listener.

28 Apr 2008, 5:13 AM
The XML response that I used is it correct?
Because the event loadexception for the HttpProxy is not fired when i try to set it.
Instead the load event is fired.

28 Apr 2008, 5:56 AM
Looks OK. You'l have to step through XmlReader using Firebug

Break at the following line in ex-all-debug.js and see what is in the variables, and what comes out of the selectValue call etc. It should extract your success element value. It will have newline before and after though, so that may affect it.

this.xmlData = doc;
var root = doc.documentElement || doc;
var q = Ext.DomQuery;
var recordType = this.recordType, fields = recordType.prototype.fields;
var sid = this.meta.id;
var totalRecords = 0, success = true;
totalRecords = q.selectNumber(this.meta.totalRecords, root, 0);

if(this.meta.success){ <-- break here
var sv = q.selectValue(this.meta.success, root, true);
success = sv !== false && sv !== 'false';
var records = [];
var ns = q.select(this.meta.record, root);
for(var i = 0, len = ns.length; i < len; i++) {
var n = ns[i];
var values = {};
var id = sid ? q.selectValue(sid, n) : undefined;
for(var j = 0, jlen = fields.length; j < jlen; j++){
var f = fields.items[j];
var v = q.selectValue(f.mapping || f.name, n, f.defaultValue);
v = f.convert(v, n);
values[f.name] = v;
var record = new recordType(values, id);
record.node = n;
records[records.length] = record;