PDA

View Full Version : Problem Loading data to store



pferril
20 Aug 2009, 8:16 AM
Hi all (again), im having trouble populating a store, im building a list with online users, that is populated from a xml (im working with maverick). Im getting the xml from the urk "keepalive.m?xml=0" every 4 seconds (im using taskrunner for it). The thing is that im getting the xml on the response, on every hit (the values i nees are between the "value" nodes)


<?xml version="1.0"?>
<KeepAlive xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<results><GestionarUsuarioChat>
<value>
<idUsuario>65478</idUsuario>
<nombre>Name</nombre>
<apellido>Lastname</apellido>
<hospital>hospital</hospital>
<provincia>State</provincia>
</value>
</GestionarUsuarioChat>
</results><formParam>
</formParam>
<language>es</language>
<messages>
</messages>
<errors/>
<CurrentHospital>CH</CurrentHospital>
<CurrentAvisar>S</CurrentAvisar>
<CurrentPerfiles> :7:</CurrentPerfiles>
<HasMoreProfile>N</HasMoreProfile>
<CurrentUserName>CurrentUser</CurrentUserName>
<CurrentEmail>[email protected]</CurrentEmail>
<idUsuario>565564</idUsuario>
<CurrentLoginProfile>
<anyType xsi:type="xsd:int">7</anyType>
</CurrentLoginProfile>
<CurrentTitulo>&gt;</CurrentTitulo>
<CurrentSexoM>True</CurrentSexoM>
</KeepAlive>
I declare the record for it, and then load the data to the store (no exceptions on the load of it), but if i debug with firebug, the store is ALWAYS empty.
(I´ve attached images of the firebug to further clarification)

Here´s the code


Ext.onReady(function () {

var out = new Ext.form.DisplayField({
cls: 'x-form-text',
id: 'out'
});

var p = new Ext.Panel({
title: 'Usuarios Online',
//frame:true,
width: 170,
height: 300,
layout: 'fit'

,
items: [out]
}).render("chat");

var task = {
run: updateClock,
interval: 4000 //1 second
}
var runner = new Ext.util.TaskRunner();
runner.start(task);

});

var updateClock = function () {
var usuarios = GetData();
var out = Ext.getCmp('out');
out.append(String.format('<p><i>{0}</i></p>', usuarios.data.Hospital));
out.el.scroll('b', 100000, true);
}

var GetData = function () {
var OnlineRecord = Ext.data.Record.create([{
name: 'idUsuario',
mapping: 'idUsuario',
type: 'int'
},
{
name: 'nombre',
mapping: 'nombre',
type: 'string'
},
{
name: 'apellido',
mapping: 'apellido',
type: 'string'
},
{
name: 'hospital',
mapping: 'hospital',
type: 'string'
},
{
name: 'provincia',
mapping: 'provincia',
type: 'string'
}
//,{ name: 'Nuevo', mapping: 'Nuevo', type: 'string' }
]);

var readerUsuariosOnline = new Ext.data.XmlReader({
record: 'value'
},
OnlineRecord);

var usuariosOnline = new Ext.data.Store({
url: 'KeepAlive.m?xml=0',
method: 'POST',
reader: readerUsuariosOnline
});

usuariosOnline.load();
usuariosOnline.addListener('loadexception', function () {
alert('usuariosOnline Data Load Exception');
});

usuariosOnline.addListener('load', function () {
//alert('usuariosOnline Data Loaded');
});

return usuariosOnline;
}

Im going nutz here, any ideas?

Tnks in advance

pferril
21 Aug 2009, 4:41 AM
Im gonna auto answer this one, there´s nothing wrong with mi code, its working, the problem was the firebug. For some reason (im still clueless of why this is happening) it just sows mi data store empty.

Ok, i hope the code help someone; tnks for the space, and see you all soon

nicobarten
21 Aug 2009, 4:51 AM
The latest firebug in combination with firefox 3.5 was a bit buggy on my friends computer too...