Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    56
    Vote Rating
    2
    korax is on a distinguished road

      0  

    Default MVC: Loader capitalizes subfolder names, tries to instantiate wrong class

    MVC: Loader capitalizes subfolder names, tries to instantiate wrong class


    Beta 3. When loading controllers within sub-folders of "app/controller", the loader appears to be capitalizing the first letter of sub-folder names. Though controller files in sub-folders load correctly (on IIS), controller classes are instantiated incorrectly using the capitalized folder name, resulting in an error.

    Contents of app/controller/sub/MyController.js:
    Code:
    Ext.define('MyApp.controller.sub.MyController', {
      extend: 'Ext.app.Controller'
    });
    Running the code below results in:

    Code:
    [Ext.Loader] Synchronously loading 'MyApp.controller.Sub.MyController' ...
    GET http://192.168.0.1/app/controller/Sub/MyController.js?_dc=1303068687990 200 OK 6ms
    Exception: Cannot create an instance of unrecognized class name / alias: MyApp.controller.Sub.MyController
    Code:
    Ext.onReady(function() {
      Ext.Loader.setConfig({enabled: true});
      Ext.onReady(function() {
        Ext.create('Ext.app.Application', {
          controllers: ['sub.MyController'],
          views: ['sub.MyView'],
          autoCreateViewport: false,
          name: 'MyApp'
        });
      });
    });
    Also seen when loading stores in sub-folders of "app/store" from controller classes.

  2. #2
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,664
    Vote Rating
    6
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    naming convention is normal part of resolving file paths by classnames. Remind that paths are case-sensitive.
    We are only missing the documentation of this naming convention:

    Code:
    [objectName].[folder][subfolder, optional].[filename]
    folder, subfolder, filename are always UpperCamelCase, '.js' will be appended on filename.

    Use it and it will work.
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  3. #3
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    56
    Vote Rating
    2
    korax is on a distinguished road

      0  

    Default


    As far as I know, the naming convention is: Application.everything.else.ClassName, and if that's the case, the loader is incorrectly capitalizing the "else" in this case. Also, this is not a problem with the "view" folder: classes inside subfolders of "view" are correctly instantiated.

  4. #4
    Sencha User
    Join Date
    Mar 2011
    Location
    Germany
    Posts
    198
    Vote Rating
    1
    Nickname is on a distinguished road

      0  

    Default


    I think this is a bug.

    In the MVC demos there are views defined in subfolders, which are lowercase

    PHP Code:
    #cat examples/app/nested-loading/app/view/book/SideBar.js 
    /**
     * The sidebar view for the application. Used to display a list of books.
     * @extends Ext.DataView
     */
    Ext.define('Books.view.book.SideBar', {
        
    alias'widget.booksidebar',
    // [....] 
    And in the Controller
    PHP Code:
    Ext.define('FV.controller.Articles', {
        
    extend'Ext.app.Controller',
    // [...]
        
    views: ['article.Grid''article.Preview'], 
    This should be possible for stores.


    If I modifed the Ext.factory() method with the following snippet, than it works.

    PHP Code:
    // around line 3980 in ext-all-debug.js or line 6474 in ext-core-debug.js
    // original code
    if (namespace !== undefined && name.indexOf(namespace) === -1) {
            
    name = namespace + '.' Ext.String.capitalize(name);
    }

    // new code 
    if (namespace !== undefined && name.indexOf(namespace) === -1) {
        if(
    name.indexOf(".") > -1) {
            var 
    splitname name.split(".");
            
    name Ext.String.capitalize(splitname.pop());
            
    name = namespace + "." splitname.join(".") + "." +  name;  
        } else {
            
    name = namespace + '.' Ext.String.capitalize(name);
        }

    Now I can name the namespaced stores in the controller like...
    PHP Code:
    Ext.define('MVC.controller.MainController', {
        
    extend'Ext.app.Controller',
        
    stores: ['navigation.TreeMenu'], 
    Without the modification the store "MVC.store.navigation.TreeMenu" definition file was loaded from "app/store/Navigation/TreeMenu.js" (failed), now its "app/store/navigation/TreeMenu.js".

    Didn't run tests for any side effects with this change.


    The smaller workaround is, to uppercase the first subfolder in store folder. But this would break the coding guidelines

  5. #5
    Sencha Premium Member
    Join Date
    Feb 2009
    Posts
    316
    Vote Rating
    3
    azuroff will become famous soon enough

      0  

    Default


    Quote Originally Posted by steffenk View Post
    We are only missing the documentation of this naming convention:
    The naming convention is documented in the "Ext JS 4 Class System - the Must Read Manual" guide -

    The top-level namespaces and the actual class names should be in CamelCased, everything else should be all lower-cased. For example:

    MyCompany.form.action.AutoLoad

  6. #6
    Ext JS Premium Member bregard's Avatar
    Join Date
    Jul 2008
    Posts
    26
    Vote Rating
    0
    bregard is on a distinguished road

      0  

    Default


    Quote Originally Posted by korax View Post
    As far as I know, the naming convention is: Application.everything.else.ClassName, and if that's the case, the loader is incorrectly capitalizing the "else" in this case. Also, this is not a problem with the "view" folder: classes inside subfolders of "view" are correctly instantiated.
    Same problem here. Is this filed as a bug?

  7. #7
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    56
    Vote Rating
    2
    korax is on a distinguished road

      0  

    Default


    Quote Originally Posted by bregard View Post
    Same problem here. Is this filed as a bug?
    Doesn't look like it.

  8. #8
    Sencha Premium Member
    Join Date
    Feb 2009
    Posts
    316
    Vote Rating
    3
    azuroff will become famous soon enough

      0  

    Default


    I didn't see a specific bug for this (although "[EXTJSIV-1332] - Application.getController not using Ext.Loader" looks like it could be it), but I verified that it's working in 4.0.0.

Similar Threads

  1. Do you like the new Field class names?
    By Steffen Hiller in forum Sencha Touch 1.x: Discussion
    Replies: 26
    Last Post: 12 Nov 2010, 10:51 AM
  2. How to define and instantiate a new class
    By Luca D'Antona in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 1 Sep 2010, 4:46 AM
  3. Dynamically instantiate a class
    By bkraut in forum Ext 3.x: Help & Discussion
    Replies: 7
    Last Post: 28 Sep 2009, 3:13 AM
  4. How to instantiate an object of the same class as "this"?
    By mherger in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 24 May 2007, 12:05 PM

Thread Participants: 4

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi