PDA

View Full Version : Some SDK tools/dynamic loader questions



estesbubba
12 Apr 2012, 6:30 AM
Converting our app to use the Sencha SDK tools and the dynamic loader. Previously we were defining all JavaScript in our JSP. We do have some questions though.

1. It appears that most Ext classes are automatically loaded but not all of them. For example on a FormPanel we use textfield, selectfield, hiddenfield, button, and container. I had to put Ext.field.Hidden in the requires but not the others. Is this correct?

2. Every time I reload the page I lose my breakpoints which stinks. Since dynamic loading seems to be the preferred method for development surely there has to be a way to keep breakpoints?

3. It appears that SDK tools wants my app to be called app.js. We have one product that actually has 3 entry apps - DeviceOrder.js, DeviceActivation.js, and AccountMaint.js. How can I use SDK tools 'sencha app build' to create these 3 apps instead of just app.js?

mitchellsimoens
12 Apr 2012, 6:56 AM
Correct. Some views will require other views in the framework code.
This is because caching is disabled so the loader can always count on loading the freshest code and not let the browser cache. You can disable this via Ext.Loader.setConfig({ disableCaching : false });
You can change the app.js by editing app.json. You will see app.js in the js array. I have not tried this but may work.

estesbubba
12 Apr 2012, 7:09 AM
So on #2 with the caching and breakpoints - how to people generally use dynamic loading and debugging? By default it doesn't allow it without changing a config. So do you change this config back and forth whenever you want to debug? Always leave it set to false? Or just don't write code with bugs?

mitchellsimoens
12 Apr 2012, 7:32 AM
I always write code without bugs! :D

I usually leave the disableCaching to true until I need to track down a bug then I set it to false so that my breakpoint can stick after refresh. Other way is to use debugger; in your code and that will stop it regardless of caching but you have to remember to remove it when you are done.

estesbubba
12 Apr 2012, 8:28 AM
Here is what I ended up doing so we can change on the fly using query string:



Csg.beforeLaunch = function () {
var params = Ext.urlDecode(location.search.substring(1)),
dc = Ext.isDefined(params.dc) ? params.dc === 'true' : true;


Ext.Loader.setConfig({
disableCaching: dc,
paths: {
'Ext': 'sdk/src',
'Csg': 'app',
'Csg.common': '../cxpe-common/js/touch2/common'
}
});
}();

Jacky Nguyen
13 Apr 2012, 1:25 AM
You don't have to do that yourself, it's already done. Just append "?breakpoint" to the query string to disable cache buster on the fly.

mitchellsimoens
13 Apr 2012, 3:55 AM
You don't have to do that yourself, it's already done. Just append "?breakpoint" to the query string to disable cache buster on the fly.

This does not work for your application classes

Jacky Nguyen
13 Apr 2012, 10:40 PM
This does not work for your application classes

It does, unless there's a line in your code setting 'disableCaching' to false explicitly, which will override that.

mitchellsimoens
16 Apr 2012, 3:57 AM
It does, unless there's a line in your code setting 'disableCaching' to false explicitly, which will override that.

Not to argue but I have an app written in 2.0.1 and setting breakpoint param has no affect on application class. I have no Ext.Loader.setConfig anywhere in my code, would only put that in app.js anyway.

estesbubba
16 Apr 2012, 8:32 AM
Not to argue but I have an app written in 2.0.1 and setting breakpoint param has no affect on application class. I have no Ext.Loader.setConfig anywhere in my code, would only put that in app.js anyway.

Same here

Jacky Nguyen
16 Apr 2012, 2:05 PM
You guys are probably using sencha-touch-all-debug.js, only sencha-touch-debug.js currently has that little code appended. I've put it in for the 'all' version as well for 2.0.1 release.