-
4 Feb 2013 3:04 AM #1
Answered: Managing Dependences between Classes
Answered: Managing Dependences between Classes
Hi all, I had a .jsp page tha generate a Ext Class like:
in my app.js I initialze Ext.application() in Ext.onReady, and also I require all required classes. This work well until required classes are loaded by dynamic loader, but when I compile classes using sencha cmd I cannot instantiate some of my required classes, since it depend on the ApplicationData member. The class is like:Code:<script src="ext/ext-dev.js"></script> <script src="app.js"></script> <script> Ext.define('ApplicationData', { singleton: true, contextPath: '<%=request.getContextPath()%>' }): </script>
In fact, afte compilation with sencha cmd the url memeber is defined as url: 'undefined/store' Is the only solution initialize url in constructor?Code:Ext.define('MyApp.store.MyStore', { requires: ['ApplicationData'], proxy: { type: 'ajax', url: ApplicationData.contextPath + '/store' } });Last edited by elettronik; 4 Feb 2013 at 3:06 AM. Reason: Clarification
-
Best Answer Posted by mitchellsimoens
The issue with that is that MyApp.store.MyStore won't be defined before the ApplicationData class is loaded and define/instantiated which is exactly what you want. However, the browser has already eval'd the file for the MyStore and found that ApplicationData does not exist. In a build this will indeed work but during development since the ApplicationData does not exist before the MyStore's file is eval'd by the browser it will not work. To get around this, you would have to Ext.require ApplicationData in app.js so it loads before the MyStore is loaded or define the proxy in the constructor method of MyStore.
-
6 Feb 2013 2:51 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
The issue with that is that MyApp.store.MyStore won't be defined before the ApplicationData class is loaded and define/instantiated which is exactly what you want. However, the browser has already eval'd the file for the MyStore and found that ApplicationData does not exist. In a build this will indeed work but during development since the ApplicationData does not exist before the MyStore's file is eval'd by the browser it will not work. To get around this, you would have to Ext.require ApplicationData in app.js so it loads before the MyStore is loaded or define the proxy in the constructor method of MyStore.
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.
-
6 Feb 2013 11:52 PM #3
In the end I solved problem by putting proxy url in constructor, but the situation for me is the opposite of what you said: during development I load MyStore, after onReady event since that view is loaded as dependency of already loaded class. But during the build the class will be packed on a file that is loaded before onReady event, so the problem in production version.
Hope this will help someone other.


Reply With Quote