Success! Looks like we've fixed this one. According to our records the fix was applied for a bug in our system in a recent build.
  1. #1
    Sencha Premium Member vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Chisinau, Moldova
    Posts
    642
    Vote Rating
    25
    vadimv will become famous soon enough vadimv will become famous soon enough

      0  

    Default [4.1.1] Controller's modules load problem

    [4.1.1] Controller's modules load problem


    If in a controller I set the model and store configs then I get a file load error with a strange path: app/controller/Main.js/model/file.js .

    Then I took a look in controllers method "onClassExtended" and seems that this line is the reason of load fail:
    Code:
    namespace = Ext.Loader.getPrefix(className) || match[1]; // = "AppNamespace.controller.Main" || "AppNamespace";
    
    If "namespace" var would have the second value "AppNamespace" then load will be ok
    Last edited by vadimv; 1 Oct 2012 at 3:27 AM. Reason: sentence correction

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,854
    Vote Rating
    610
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Not really sure what the bug is here, can you elaborate a bit?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha Premium Member vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Chisinau, Moldova
    Posts
    642
    Vote Rating
    25
    vadimv will become famous soon enough vadimv will become famous soon enough

      0  

    Default


    there sth wrong here ?, is there sth else to do after app generation with Sencha Cmd 181 on MacOSX 10.6.8 (besides enabling Loader) so that not to receive that loading error. To reproduce it is very simple, just generate the app and then generate a model and then try to build that app.

  4. #4
    Sencha User
    Join Date
    Oct 2010
    Posts
    75
    Vote Rating
    4
    devnullable is on a distinguished road

      0  

    Default


    Vadimv, did you find any solution?

    I encountered the same problem. I am not 100% sure but this may have to do something where you put your models and views declarations. If you define them inside Ext.application everything seems to work ok but if you define them in the controller then it fails like you said.

    For example you have controller Car, and model Car. If you define models: ['Car'] inside controller Car then Loader tries to load /app/controller/Car.js/model/Car.js which naturally fails. But if you define models: ['Car'] inside Ext.application then it should work.

    Where we should define models and views? I would like to declare them in corresponding controller, not in Ext.application.

  5. #5
    Sencha User
    Join Date
    Oct 2010
    Posts
    75
    Vote Rating
    4
    devnullable is on a distinguished road

      0  

    Default


    If I want to define store in corresponding controller I have to use fully qualified name

    Code:
    requires: ['MyCarApp.stores.Car'],
    stores: ['MyCarApp.stores.Car']
    which of course generates getter method named getMyCarAppStoresCarStore which is not so cool

    I am using 4.1.1a and Sencha Cmd v3.0.0.190

  6. #6
    Sencha Premium Member vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Chisinau, Moldova
    Posts
    642
    Vote Rating
    25
    vadimv will become famous soon enough vadimv will become famous soon enough

      0  

    Default


    devnullable@, yes I know about all these things, my temporary solution is to take the namespace from the match[1]. I remember that in previous versions I have hadn't such issues, was just specifying app's path in Loader and everything worked, but with the new Sencha Cmd sth is working differently, which I don't know what yet.

  7. #7
    Sencha User
    Join Date
    Oct 2010
    Posts
    75
    Vote Rating
    4
    devnullable is on a distinguished road

      0  

    Default


    getPrefix function has following code:
    Code:
    if (paths.hasOwnProperty(className)) 
       return className;
    }
    bootstrap.js indeed has a entry for AppName.controller.Main and therefore hole class name is returned. If I comment out the controller entry in bootstrap.js the if statement returns false and the rest of the getPrefix function works as expected and returns only the AppName.

    I don't know what is the purpose of the shown code and why it returns fully qualified path?

  8. #8
    Sencha Premium Member vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Chisinau, Moldova
    Posts
    642
    Vote Rating
    25
    vadimv will become famous soon enough vadimv will become famous soon enough

      0  

    Default


    Yes, my conclusion to this issue is that until now we set Loader paths by ourself,everything worked ok, as was bootstrap introduced and new Sencha Cmd, this line of code from controller class :
    Code:
    namespace = Ext.Loader.getPrefix(className) || match[1];
    doesn't work anymore, why !!? we know(you just mentioned above). So I still think that
    Code:
    namespace =match[1];
    is a solution, getPrefix is just optional there, because I don't see the reason of using it, since match is always not null and has the right namespace value.
    Code:
       onClassExtended: function(cls, data, hooks) {
            var className = Ext.getClassName(cls),
                match = className.match(/^(.*)\.controller\./),
                namespace,
                onBeforeClassCreated,
                requires,
                modules,
                namespaceAndModule;
            
            if (match !== null) {
                namespace = Ext.Loader.getPrefix(className) || match[1];
                onBeforeClassCreated = hooks.onBeforeCreated;
                requires = [];
                modules = ['model', 'view', 'store'];
    
    
                hooks.onBeforeCreated = function(cls, data) {
                    var i, ln, module,
                        items, j, subLn, item;
    
    
                    for (i = 0,ln = modules.length; i < ln; i++) {
                        module = modules[i];
                        namespaceAndModule = namespace + '.' + module + '.';
    
    
                        items = Ext.Array.from(data[module + 's']);
    
    
                        for (j = 0,subLn = items.length; j < subLn; j++) {
    p.s Also everything what was said in this thread is enough to qualify it as a Bug or Not, just inforequest can't be anymore.

  9. #9
    Sencha User
    Join Date
    Oct 2010
    Posts
    75
    Vote Rating
    4
    devnullable is on a distinguished road

      1  

    Default


    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.1.1a and cmd v3.0.0.190
    Browser versions tested against:
    • IE9
    • FF3
    • Chrome 22.0.1229.79
    • Safari 4
    DOCTYPE tested against:
    • Default
    Description:
    • When store is defined in controller's stores property Ext.Loader fails to load store's JavaScript file because of incorrect path. When controller is named BookingSearch and store is named Bookings, Loader tries to load store's JavaScript file as app/controller/BookingSearch.js/store/Bookings.js
    Steps to reproduce the problem:
    • Use Sencha Cmd to make new application
    • Create a new controller or use the Main controller created by default
    • Create a new store to app/stores folder
    • Add store to controller: stores: ['Bookings']
    • Run sencha app refresh to update bootstrap.js
    • Load index.html in browser
    The result that was expected:
    • Working application
    The result that occurs instead:
    • Ext.Loader fails to load store's JavaScript file because of incorrect path
    Test Case:
    Code:
    Ext.define('MyApp.controller.BookingSearch', {    
        extend: 'Ext.app.Controller',
        stores: ['Bookings']
    });


    HELPFUL INFORMATION

    Possible fix:
    • Ext.Loader's getPrefix function has following
    • Code:
      if (paths.hasOwnProperty(className))   return className; }
    • Because bootstrap.js has entry for MyApp.controller.BookingSearch this code returns controller's fully qualified path instead of prefix.
    • I have commented out code above and let rest of the getPrefix function to do the job correctly
    Operating System:
    • Ubuntu
    • Max OS X
    • Windows 7

  10. #10
    Ext JS Premium Member
    Join Date
    Jun 2010
    Location
    Miami, Florida
    Posts
    7
    Vote Rating
    0
    yoniel2000 is on a distinguished road

      0  

    Default Hello everyone!

    Hello everyone!


    Any update on this? Regards