Question

For some reason, Sencha Cmd fails when it parses app.js with custom code. Below, is a snippet from an application I'm deploying to testing (unminified JavaScript but in a single file) or to production (minified JavaScript).

The browser throws the following JavaScript exceptions from the deployed folder (with all-classes.js):

(note: the folder with all js source code runs fine)

GET http://localhost/App/App/model/app/CheckTreeNode.js?_dc=1396967410158 404 (Not Found) all-classes.js:10841
GET http://localhost/App/App/store/app/UserPreferenceNodes.js?_dc=1396967410159 404 (Not Found) all-classes.js:10841
GET http://localhost/App/app/controller/ViewportAdmin.js?_dc=1396967410177 404 (Not Found) all-classes.js:10841

...

Uncaught Error: [Ext.Loader] Failed loading 'App/model/app/CheckTreeNode.js', please verify that the file exists all-classes.js:11259
Uncaught Error: [Ext.Loader] Failed loading 'App/store/app/UserPreferenceNodes.js', please verify that the file exists all-classes.js:11259
Uncaught Error: [Ext.Loader] Failed loading 'app/controller/ViewportAdmin.js', please verify that the file exists 

I tried fixing things by adding a "requires" config in my Ext.application class, but that didn't help. How can I force these files to be seen by Sencha Cmd? Sencha Touch has a solution by allowing you to add files to "app.json". Perhaps there is a similar solution for ExtJS applications that I'm unaware of?

If there are more elegant solutions, I'm open to them. I needed the user preferences in the constructor of a bunch of my classes, so this was the only place I could get it to load and be ready when those are called. If there is a different way to load data that can be available when building classes within MVC, I'm fine with a different solution for that. As for having two viewports, this is what I found to work, so that's what ViewportAdmin is. Just a second viewport.

app.js source code:

Ext.application({ name: 'App',

extend: 'App.Application',
requires: [
    'App.store.app.UserPreferences',
    'App.view.ViewportAdmin'
],
autoCreateViewport: false,
launch: function () {        

    Ext.StoreManager.lookup('App.store.app.UserPreferences').on('load', function () {

        if (window.location.href.indexOf('/App/index.aspx?admin=true') > -1) {
            Ext.create('App.view.ViewportAdmin');
        }
        else if (window.location.href.indexOf('/App/index.aspx') > -1) {
            Ext.create('App.view.Viewport');
        }
    });


}

});

Was it helpful?

Solution

The problem wasn't due to what I suspected. After deploying the app to testing (ran command "sencha app build testing", I put a breakpoint on the two lines of code below. It turns out that the controller that it errored on had the store which was not being used. It failed because of that. The CheckTreeNodes.js was the model being used in that store. I just removed it from the stores list to resolve it.

code in all-classes.js (generated from YUI compressor I think):

script.src = url;
(Loader.documentHead || document.getElementsByTagName('head')[0]).appendChild(script);

I looked at the call stack in Google Chrome and found that the anonymous function call (in the call stack) was showing the list of stores from the ViewportAdmin controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top