PDA

View Full Version : store.load is inconsistent when running more than one



vishpool
4 Jun 2007, 9:23 AM
Hi Guys,

I am not sure if I am doing something wrong, or if it's just how Ext is behaving. I have two custom panels, each with it's own ds/httpproxy calls. If I just run one, I have no problems loading in the data. But if I have both running, it's inconsistent. One, or sometimes both, give a loadexception (resp.status = '-1'). But, I am not sure why this would happen. Any clue?

Here's my code:


Ext.StandardResultsPanel = function(el, query, status, config){
Ext.StandardResultsPanel.superclass.constructor.call(this, el, config);
this.addEvents({resultclick: true});

this.query = query || 'cooperation';
this.status = status;

var doc = Ext.data.Record.create(['title', 'summary', 'source', 'docid']);
this.store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'views/standard/data.php?request=results&query=' + this.query,
timeout: 600
}),
reader : new Ext.data.XmlReader({record: 'doc'}, doc)
});
this.status.getEl().removeClass('done');
this.store.on('load', this.onLoad, this);
this.store.load();

this.store.on('loadexception', function(a,conn,resp) { alert(resp.status); }, this);

var tpl = new Ext.Template('<div class="result">'
+ '<div class="result_headline">Title: {title}</div>'
+ '<div class="result_summary">{summary}</div>'
+ '<div class="result_source">Source: {source}</div>'
+ '</div>');

this.results = new Ext.View(el, tpl, {store: this.store, singleSelect: true, selectedClass: 'result_selected'});
this.results.on('click', this.onResultClick, this);
};

Ext.extend(Ext.StandardResultsPanel, Ext.ContentPanel, {
onResultClick: function(e){
this.fireEvent('resultclick', this, this.store.getAt(this.results.getSelectedIndexes()[0]));
},

onLoad : function(){
this.status.getEl().addClass('done');
}
});



Ext.FacetsPanel = function(el, query, status, config){
Ext.FacetsPanel.superclass.constructor.call(this, el, config);
this.addEvents({facetclick: true});

this.query = query || 'cooperation';
this.status = status;

var fields = Ext.data.Record.create([
{name: 'field', mapping: '@name'},
{name: 'id', mapping: '@num'},
{name: 'term', mapping: 'term'},
{name: 'count', mapping: '[email protected]'}
]);

this.reader = new Ext.data.XmlReader({record: 'field'}, fields);
this.store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'views/standard/data.php?request=facets&query=' + this.query,
timeout: 600
}),
reader : this.reader
});
this.status.getEl().removeClass('done');
this.store.on('load', this.onLoad, this);
this.store.load();

this.store.on('loadexception', function(a,conn,resp) { alert(resp.status); }, this);

var ul = Ext.get(el).createChild({tag:'ul'});
var ftpl = new Ext.Template('<li><img src="images/results/arrow_contracted.png"">&nbsp;{field}'
+ '<div id="facets_field_{id}"><ul>{terms}</ul></div>');

var ttpl = new Ext.Template('<li class="facets_term">{term} ({count})');

this.facets = new Ext.View(ul, '{html}', {store: this.store});
this.facets.prepareData = function(data, index, record) {
var html = ftpl.applyTemplate({field: data['field'], id: data['id'], terms: ttpl.applyTemplate(data)});
return {
html: html
}
}

this.facets.on('click', this.onFacetClick, this);
};

Ext.extend(Ext.FacetsPanel, Ext.ContentPanel, {
onFacetClick: function(e) {
this.fireEvent('resultclick', this, this.store.getAt(this.facets.getSelectedIndexes()[0]));
},

getId: function() {
return this.el.id;
},

onLoad : function(){
this.status.getEl().addClass('done');
}
});

Thanks in advance!

vishpool
4 Jun 2007, 9:34 AM
Also, I have been trying to track it down with firebug (w/o luck), but this is interesting:

Firebug doesn't show any data/response from time to time...see attached. It's inconsistent again in that its almost like the data is loaded (with the timer stopped), but it still shows 'loading...'.

tryanDLS
4 Jun 2007, 10:06 AM
You probably should set some BPs in the YUI Connect object to see when it's getting an error. -1 looks to be the status of an aborted request. You might check your server logs to see if its timing out or being dropped for some other reason.

vishpool
5 Jun 2007, 5:44 AM
I can't seem to track it down...just because its inconsistent. Question: is HttpProxy multi-thread safe? That is, is it safe to run multiple requests at the same time (but different objects/instances, ofcourse).

I checked the server logs, and I don't see any issues on that end.

vishpool
5 Jun 2007, 6:08 AM
Figured it out...I was actually using 'timeout' param (not sure why exactly), and '600' as the value wasn't working well. So, I just took the timeouts out (mouthful) and it works now!!!