PDA

View Full Version : Load, Read, Exception Event on JsonStore



gabrielstuff
28 Sep 2010, 6:19 PM
Hi all !
I'm kind of getting crazy with this.
The new read event seems to work great but their is somekind of behavior that I think is quiete repulsing.
If your app is offline and you want to load data from a jsonStore with a scripttag proxy there is no event to prevent for masking and then waiting indefinitely for a futur read event that will never happen.

It seems that the event exception is here... but I can not catch it.

Followin the code I pass thru lot of :

onProxyRead:Ext.emptyFn

And I looked everywhere for any fireevent... but did'nt see it...
Any help would be greatly appreciate. Actually, it would be logical to help me fix this because, in kitchen sink, if you try in offline, and then go to data example and touch json or YQL, the mask layout break the app. I mean it appears and give some kind of a modal window that you can not move away.
Then you are forced to reload...

Hope it is clear and some one found a solution :)

Thanks !

G

gabrielstuff
29 Sep 2010, 7:28 AM
Actually I do not get how to know if a ressource is available or not... maybe I'll should check for this first ? Any hints would be apreciate.

evant
29 Sep 2010, 3:24 PM
I'm not really sure what you're saying here, I don't see that code anywhere in the ScriptTagProxy.

gabrielstuff
29 Sep 2010, 3:55 PM
Ok, so I was reading thru the code of 0.95.

So I go to jsonstore :


Ext.data.JsonStore = Ext.extend(Ext.data.Store, {

Then data.store :

line 4898

Ext.data.Store = Ext.extend(Ext.data.AbstractStore, {

line 5073 :


read: function(options) {
options = options || {};
Ext.applyIf(options, {
group : {field: this.groupField, direction: this.groupDir},
start : 0,
limit : this.pageSize,
addRecords: false
});
return Ext.data.Store.superclass.read.call(this, options);
},

onProxyRead: function(operation) {
var records = operation.getRecords();
this.loadRecords(records, operation.addRecords);
this.fireEvent('read', this, records, operation.wasSuccessful());


var callback = operation.callback;
if (typeof callback == 'function') {
callback.call(operation.scope || this, records, operation, operation.wasSuccessful());
}
}Then reading to the superclass :

line 4524

onProxyRead: Ext.emptyFn,
And so the other thing is that, I can not get the damn exception event... Actually I was wondering why do not we have a success and failure callback function like for Ajax.

In the doc, you talk about :
Common Events you may want to set are:


beforerequest (http://dev.sencha.com/deploy/touch/docs/output/Ext.data.Connection.html#Ext.data.Connection-beforerequest)
requestcomplete (http://dev.sencha.com/deploy/touch/docs/output/Ext.data.Connection.html#Ext.data.Connection-requestcomplete)
requestexception (http://dev.sencha.com/deploy/touch/docs/output/Ext.data.Connection.html#Ext.data.Connection-requestexception)


// Example: show a spinner during all Ajax requests Ext.Ajax.on('beforerequest', this.showSpinner, this); Ext.Ajax.on('requestcomplete', this.hideSpinner, this); Ext.Ajax.on('requestexception', this.hideSpinner, this);This is really cool. With the read event it is now possible :) but :( no exception and no event to indicate that we should better stop searching for something that does not exist...

I am actually seeking throuth a solution and going to use something really crappy... and I do not like that :(

Thank you by advance for your future reply/solution

gabrielstuff
3 Oct 2010, 3:56 PM
No news from here ??
So how do you manage to make it ? in 0.96 the problem still the same.
One button to call for jsonp and if you lost the connexion you end up with a spinner that keep loading infinitely...
The main problem about mobile phone is that you can loose your connectivity.

Wait for a reply.
At least the addmask option should aply to the list only or the panel that will be displayed. So it could allow to keep navigate in the other places.

Thank you !

Shane F
5 Oct 2010, 11:11 AM
To your post in the other thread, yes. It seems related.

roady001
12 Oct 2010, 7:40 AM
I had the same problem, and used a different approach to solve it.

I have the following (model not shown):


var ListStore = new Ext.data.Store({
model: 'List',
sorters: 'name',
getGroupString: function (record) {
return record.get('name');
},
proxy: Proxy,
autoLoad: true,
listeners: {
beforeload: function () {
Ext.getBody().mask(false, '<div class="app-loading" id="mask">Loading list...</div>');
},
load: function () {
Ext.getBody().unmask();
}
}
});


And add the following function:



var doNetworkCheck = function () {
if (Ext.fly('mask') != null) {
Ext.getBody().unmask();
Ext.Msg.alert("No Internet connection", "There was an error connecting to the Internet.");
}
};

setTimeout(doNetworkCheck, 8000);


So it works by checking if the div with id 'mask' still exists after 8 seconds. If it does, than it will unmask the UI and give a message to the user. Works for me, hope it also helps your problem.