PDA

View Full Version : Panel keeps loading when server error.



Albareto
25 Apr 2010, 11:24 PM
Hi folks,

Hi have a Panel that I load when an element in my screen is clicked. As far as the information comes correctly it's shown and I have no problem but if I get an error in server side and the response returns an error my panel keeps on loading.

I tried to catch the 'failure' event on the updater but once there I cannot change the text of the panel to show some error text instead of the 'loading...'.



var updater = myPanel.getUpdater();
updater.on('failure', function(el, response)
{
if(response.status && response.status === 500)
{
this.getUpdater().abort(); //this do nothing I can see (??)
this.body.html = '<div>Failure!</div>'; //this is not shown
this.updater = null; //Why not to try? :)
this.doLayout(); // Panel doesn't do the layout as far as I can see
}
}, myPanel);I have seen this behavior also in the API GUI (http://extjs.com/deploy/dev/docs/) last week (or two weeks ago) when I had the window open and the server went down (they were migrating server and the service was off for some minutes) , then when I clicked in the tree the documentation panel opens but it keeps loading as the server is off. Well, this is exactly my problem :)

Any clue how this can solved?

Thanks in advance.

Albareto
27 Apr 2010, 12:17 AM
No ideas about this? I think it shouldn't be so difficult, probably I am missing something...

Sgt.Pepper
27 Apr 2010, 12:37 AM
What kind of object is the "updater"?

Ext.Ajax doesn't have a "failure" event! Ext.Ajax.request() accepts "failure" as a parameter in the config options. But this is not an event, so you can't attach a handler via the on() method. Look at the API:

Ext.Ajax.request({
url: 'ajax_demo/sample.json',
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
console.dir(obj);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}});

Albareto
27 Apr 2010, 12:56 AM
I get your point, and your are right as per my description, but now I re-read my text it's not completly correct, I am loading the panel, not directly doing an Ajax call (that's done internally), I think I will edit my first post as it can be confusing.

This is what actually is happening:



var myPanel = new Ext.Panel(
{
//configuration options
});
panel.load(
{
url: 'myUrl',
params: myParams

});

The Updater: http://www.extjs.com/deploy/dev/docs/?class=Ext.Updater



Provides AJAX-style update capabilities for Element objects. Updater can be used to update (http://www.extjs.com/deploy/dev/docs/output/Ext.Updater.html#Ext.Updater-update) an Ext.Element (http://www.extjs.com/deploy/dev/docs/output/Ext.Element.html) once, or you can use startAutoRefresh (http://www.extjs.com/deploy/dev/docs/output/Ext.Updater.html#Ext.Updater-startAutoRefresh) to set up an auto-updating Element (http://www.extjs.com/deploy/dev/docs/output/Ext.Element.html) on a specific interval.


Thanks for the answer ;)