-
18 Sep 2012 5:46 PM #1
[4.1.2] Ext.app.Application overwrites MyApp.app namespace
[4.1.2] Ext.app.Application overwrites MyApp.app namespace
REQUIRED INFORMATION
Ext version tested:- Ext 4.1.2
- not relevant
- ExtJs 4.1.2 introduced the new 'feature' where Ext.app.Application assigns itself to 'MyApp.app' (with MyApp being the application namespace as defined by the appName property)
- This didn't consider that users might actually use this path as namespace for class definitions, e.g. 'MyApp.app.MyClass'
- Create a class in your application's namespace in a package named 'app', like so: Ext.define('MyApp.app.SomeClass')
- The class being available and accessible via the defined namespace
- The class not being available and accessible via the defined namespace
Code:Ext.define('MyApp.app.SomeClass', { singleton: true, property: 'prop' /*...*/}); Ext.application({ uses: ['MyApp.app.SomeClass'], appName: 'MyApp', launch: function() { console.log(MyApp.app.SomeClass.property === 'prop'); // FAILS: SomeClass is undefined } });
-
18 Sep 2012 6:53 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
So what would you like us to do? Have a config for where to cache the Ext.application instance?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
18 Sep 2012 7:35 PM #3
Well,
a config or
template method or
a function Ext.app.Application#getApp() or
disable the feature by default or
...
I guess that is a decision that a Sencha developer should make.
-
18 Sep 2012 7:40 PM #4
This 'feature' was introduced in 4.1.2. Maybe not the best time to do so in a maintenance release.
Also, I recommend finding a prominent place to document the fact that it is not possible to use namespaces/class names with 'appname.app'.
It is not really obvious what is happening when it happens.
EDIT:
Maybe a good way around the documentation problem is to throw an exception when assigning the application object to a property that is not empty - and include a reference to how to reconfigure the application.
-
18 Sep 2012 8:20 PM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
18 Sep 2012 10:36 PM #6
@OP Agreed.
I've pushed up a fix so it will now be configurable by an appProperty config. Also, it will throw a warning if the default is left in place and it's overwriting something.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
20 Sep 2012 3:53 AM #7
@evan
thx.
@mitchell
thx for asking
I am happy with the chosen approach.
You found a bug! We've classified it as
EXTJSIV-7281
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote