PDA

View Full Version : [FIXED] Bug in Twitter Example



gabrielstuff
21 Oct 2010, 3:01 AM
I did not see it in the bug, so here it is :

Just go to :
http://dev.sencha.com/deploy/touch/examples/twitter/

And look at the console :


Uncaught TypeError: Object [object Object] has no method 'getTotal'
Ext.data.Reader.Ext.extend.readRecordsext-touch.js:6
Ext.data.JsonReader.Ext.extend.readRecordsext-touch.js:6
Ext.data.Reader.Ext.extend.readext-touch.js:6
(anonymous function)ext-touch.js:6
(anonymous function)

Hope it helps.

edspencer
21 Oct 2010, 12:19 PM
Thanks - this is already fixed internally and will be working again in the next release.

Steffen Hiller
27 Oct 2010, 3:54 PM
Maldito getTotal. :-/

Worked around the 0.97 bug by instantiating ScriptTagProxy directly instead of using lazy instantiation.

Now this in 0.98 (with normal instantiation and lazy instantiation):


Uncaught TypeError: Object [object Object] has no method 'getTotal' ext-touch-debug.js:8705
Ext.data.Reader.Ext.extend.readRecords ext-touch-debug.js:8705
Ext.data.JsonReader.Ext.extend.readRecords ext-touch-debug.js:8972
Ext.data.Reader.Ext.extend.read ext-touch-debug.js:8689
(anonymous function) ext-touch-debug.js:8159


Any idea?

Thanks!

Steffen Hiller
27 Oct 2010, 4:17 PM
Switched to Ext.data.JsonPStore and now I don't get any errors, but dataview and list stay empty.
The data passed to JsonReader.readRecords looks fine ... hmm

edspencer
27 Oct 2010, 4:20 PM
Are you still referring to the Twitter example? It runs correctly on all devices for me.

Usually the getTotal failure means a model has not been set on the Reader. I'll add a more descriptive error to make that less cryptic.

Steffen Hiller
27 Oct 2010, 4:23 PM
No, sorry, not the Twitter example.
The errors appear in my app. This thread was just the first thread I found that talks about that getTotal bug from 0.97.

There is no example with ScriptTagProxy or JsonPStore as far as I see .. still investigating ...

edspencer
27 Oct 2010, 4:25 PM
The Twitter example uses a ScriptTagProxy -see http://dev.sencha.com/deploy/touch/examples/twitter/

The entire unit test suite is currently passing, though STP is a really hard one to test. All of my testing with it has functioned correctly so if you can show me an instance of it failing I'd be very interested to see it!

Steffen Hiller
27 Oct 2010, 4:27 PM
Stepping through the stack now. Like I said earlier, after changing to JsonPStore, no errors appear anymore, but dataview stays empty ...

Steffen Hiller
27 Oct 2010, 4:32 PM
Ok, my JsonPStore is empty in 0.96 as well ..

I'm passing model, root, autoLoad: true, url to the JsonPStore ... but in the docs it doesn't they something about the model config option:



new Ext.data.JsonPStore({
// store configs
autoDestroy: true,
storeId: 'myStore',

// proxy configs
url: 'get-images.php',

// reader configs
root: 'images',
idProperty: 'name',
fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
})


trying to define fields directly in the store now ...

edspencer
27 Oct 2010, 4:39 PM
Best practice looks like this:



Ext.regModel('Image', {
fields: [
'name',
'url',
{name:'size', type: 'float'},
{name:'lastmod', type:'date'}
],

proxy: {
type: 'scripttag',
url : 'get-images.php'
}
});

new Ext.data.Store({
model: 'Image'
});


I'm deprecating the Store specializations as they hide the truth about the relationships between Store, Proxy, Model, Reader and Writer from the developer, which is not good.

If you make your code like the above does it do what you want it to? This is the style we advocate in the API docs and all of our examples - in your case I think you're more accustomed to Ext 3.x style :)

The only thing I can think of is that we get a fail when defining fields directly on a Store via the 'fields' config (e.g. not registering and specifying a model).

Steffen Hiller
27 Oct 2010, 4:52 PM
Ok, after adding



reader: {
type: 'json',
root: 'results'
}

to the proxy config of your example, it works now.

So, due the nature of the API I'm accessing, I have to do 2 different requests (different urls) which return both the same model.
Like when you would ask Twitter for getting following and followers users, both return model user instances.

Quick idea how to dynamically set the url when instantiating the stores? :-) (I had that before, but apparently that is not working with 0.98 anymore.

Thanks!!!

Steffen Hiller
27 Oct 2010, 5:20 PM
Hmm, tested the new scrolling with 0.98. It behaves better at first, but gets sluggish soon after.
I guess I stay with 0.96 for now. (The other layout bug from 0.97 still exists in 0.98)

I still love Sencha Touch though, don't get me wrong! ;)
After the release of my app this Friday, I can show you/everyone else better the scrolling experience in my app etc.

Anyway, thanks for the quick replies!!!

Later,
Steffen

edspencer
27 Oct 2010, 5:24 PM
The proxy can be overridden per Store - putting it on the Model gives a nice default (e.g. for models using localStorage or REST - it's always the same). In your case you can just move the proxy config from the Model to each Store and modify the url

Steffen Hiller
27 Oct 2010, 5:28 PM
Yeah, I had that, but seems not to work with 0.98. But will confirm the next days con calma. :)

Thanks anyway!!!

Steffen Hiller
28 Oct 2010, 10:46 AM
I isolated the getTotal bug from yesterday:
http://www.sencha.com/forum/showthread.php?114034-New-quot-getTotal-quot-bug-in-0.98-(worked-in-0.97)&p=531657

edspencer
28 Oct 2010, 11:51 AM
Ok I commented on that thread. Are we done on this one? I'm having trouble seeing if there actually is a bug with this :) I think it's more a configuration problem

Steffen Hiller
28 Oct 2010, 12:00 PM
Ok, I commented also on the other thread. :-P

Definitely done with this thread. It was just the first thread that came up in my search yesterday for getTotal, and I saw, that you commented on that thread, so I figured the chance that you answer before contest deadline would be higher (because you get an email notification, I guess). Anyway, my strategy seemed to have worked. :-)
Thanks again for the quick reply!