View Full Version : [CLOSED] MVC appFolder path

26 Apr 2011, 7:01 AM
I'm using a server-side framework along with ExtJS for a webapp I'm working on and am running into an annoyance with that paths Ext.Loader is getting from Ext.app.Application. I would like to place calls to Ext.Loader.setPath() in a <script> tag in my HTML page rather than within my ExtApplication(). This would allow me to adjust the paths based on the way the server side is deployed and obviate the need to hard-code paths in the JS files.

<script type="text/javascript">
Ext.Loader.setConfig({ enabled: true });
Ext.Loader.setPath('Foo', 'foo/app');
<script type="text/javascript" src="foo/app/Application.js"></script>

Looking at Ext.app.Application's constructor(), I see it's calling Ext.Loader.setPath(this.name, this.appFolder), even if appFolder is undefined, thus stomping on my earlier setPath() call. I wonder what it'd harm to wrap that call in constructor() so it's only made if the appFolder is set.

1 Jul 2011, 9:37 PM
I had the same issue and I simply referenced the path in the loader as my appFolder like so.

name: 'Foo',
appFolder: Ext.Loader.getPath('Foo'),
Then you can specify the path as you did in your code above.

28 Jan 2012, 8:03 AM
I'm using Sencha Touch 2 PR4 and I ran into the same problem. Your fix helped. Thanks NeoJS

2 Feb 2012, 2:29 PM
I thought the fix for this went into PR4 but perhaps it's in beta instead. Can you download beta 1 and see if it fixes your problem? Check out the SDK's kitchen sink example to see it in action.

4 Feb 2012, 8:46 AM
I don't think it's fixed in Beta 1 either. I tried Beta 1 and I get a bunch of 404 errors because it's not referencing the right app path. Oddly enough, it seems even worse than PR4. It's trying to access /controller-name.js instead of /appFolder/controller/controller-name.js

It's trying to get a controller from the root site. It's not even trying to look inside the default "controller" folder. i.e. controller/controller-name.js.

I specified the appFolder in the Ext.application config AND I used the Ext.Loader.setPath().

EDIT: I just downloaded the Sencha Designer Beta (http://www.sencha.com/blog/sencha-designer-2-beta-announcement/) and I tried typing my app path in the appFolder property, and I get this error:
Property must beging with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), underscores ("_")

Has something changed since PR4. My path is not the root of the website and I have specify a subfolder. So my path is "/abc/app", but when I enter that in Sencha Designer, it doesn't accept the slashes. In PR4, entering a full path worked fine (not using Designer).

4 Feb 2012, 10:31 AM
Ok I just want to be totally sure that you're a) talking about Sencha Touch (this is in the Ext JS 4 forum) and b) definitely using b1. If that's the case I'll move this to the ST2 bug forum and into the bug tracker

4 Feb 2012, 11:27 AM
crap, my apologies. I searched some keywords on google and arrived here. I'm talking about sencha touch, not extjs 4

11 Feb 2012, 6:16 PM
Ok I've been making some improvements to path handling in MVC and think one of the changes inadvertently fixed this too. This code now works as expected for me when I call my folder appFolder instead of app:

name: 'MyApp',

appFolder: 'appFolder',
views: ['MyView'],

launch: function() {

It loads MyApp.view.MyView from appFolder/view/MyView.js and correctly instantiates it in my launch function. This will be in the next release.

10 Apr 2012, 3:34 PM
In our enterprise app we keep our js assets in a separate area from our serverside generated HTML views--however, it appears when the appFolder points to a relative path (like "~/scripts/app") an error is raised saying:

Line: 5730
Error: Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required classes: DemoDbMvcApp.view.Viewport, DemoDbMvcApp.controller.Shell

(Which in essence means it can't find the ExtJs4.1 RC2 MVC controller and view js files)

As a work around, we have to inject the fullpath as a js var (serverside) and then use that in the appFolder config.

Will there be support for relative paths in the future?

11 Apr 2012, 7:01 PM
1 - Make sure you have dynamic loading enabled:

enabled: true

2 - Having dynamic loading enabled, appFolder will support both absolute and relative paths like:

appFolder: 'app'
appFolder: '/~someHomeDirectory/myJsResources'
appFolder: '../../../../../myJsResources'

3 - Also, when referencing home directories (~something), be sure to prefix it with a slash (/~something)

4 - An app.js example:

enabled: true

name: 'MyApplication',
appFolder: 'app',
// appFolder: '/~sites/MyApplicationJsResources', // home directories are supported
// appFolder: '../../../../../MyApplicationJsResources', // relative paths are supported

controllers: [

launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [{
xtype: 'MyFeature'