1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    125
    Vote Rating
    0
    oddz is on a distinguished road

      0  

    Default Auto loading Classes Using Organized Into Modules

    Auto loading Classes Using Organized Into Modules


    I am building quit a large application. The application essentially consists of 5 separate products. Therefore, instead of having a single model, view and controller directory I have several organized under a root level module directory.

    Example:

    - mod1
    -- controllers
    -- views
    -- models
    -- stores
    - mod2
    -- controllers
    -- views
    -- models
    -- stores
    ...

    I'm sure you get the idea.

    The naming convention of my classes follows this pattern:

    appname.[views | controllers | stores | models].[mod1 | mod2].NameOfClass

    Any insight would be appreciated on overriding the auto loading functionality to support the above structure.

    Thanks

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    The autoloader follows the directory structure. In your example if you would put mod1/mod2 folders inside of each view/controller/store/model folder it should do the trick.

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    125
    Vote Rating
    0
    oddz is on a distinguished road

      0  

    Default


    Well... I would really like to keep all module specific code under a single directory rather than separate it between multiple directories. That is why I was wondering how difficult it would be to override the implementation of the loader to support the structure I have. Even... where to start/look to achieve this goal.

  4. #4
    Sencha - Sencha Touch Dev Team Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      0  

    Default


    It's fairly simple to achieve what you want, just give Ext.Loader the proper mappings based on your structure. Here's how it may look like. Put these right above Ext.application(...)

    Code:
    Ext.Loader.setPath({
        'AppName.controller.mod1': 'path/to/src/mod1/controllers',
        'AppName.view.mod1': 'path/to/src/mod1/views',
        // ...
        'AppName.controller.mod2': 'path/to/src/mod2/controllers'
        // ... you get the idea
    });
    which makes every class under the 'AppName.controller.mod1.*' namespace being loaded from 'path/to/src/mod1/controllers/*', and so on. That solves the loading issue.


    However, you may have some other issues with the current MVC code base since to be honest, we've never actually tried that custom structure. I'm not surprised if the custom class names are not respected in a few places. No worries, try that out and we'll help you along in this thread.
    Sencha Touch Lead Architect

  5. #5
    Touch Premium Member senchito's Avatar
    Join Date
    Aug 2011
    Location
    Montreal, QC
    Posts
    27
    Vote Rating
    0
    senchito is on a distinguished road

      0  

    Default


    please tell me how to disable the autoloader. I had already built my own autoloader which works well and I want to keep using it.

  6. #6
    Touch Premium Member senchito's Avatar
    Join Date
    Aug 2011
    Location
    Montreal, QC
    Posts
    27
    Vote Rating
    0
    senchito is on a distinguished road

      0  

    Default


    ok so I decided to try and work with this.. I spent a lot of time programming my own autoloader but I figure yours must be more efficient.

    So just so I understand right.. if I use your autoloader (which for now I have no choice since I don't know how to disable it), then this means that I don't have to manually link to my .js files? You will do all of that on your own?

    Also.. I think I found a bug. I was having issues with your auto loader since my JS files are actually stored on a different subdomain than my html file.. luckily I was able to provide the absolute path using your

    Ext.Loader.setPath({ ... });

    code. However.. here's the funny thing. My "app" is named "app". I was only getting errors because your framework was trying to autoload my models.. so I gave it the absolute path using "app.models':

    How come it didn't ask me to specify the paths to my stores and views?

    Currently I AM loading ALL my .js files as I used to do before... so if I'm right and your framework is now autoloading some of my files.. then it means that some files are being loaded twice.

    Would love some clarification here on whether I can stop loading up my js files manually.. (or some of them).

    Also.. btw.. if you are loading my files manually than I just would like to let you know that this causes some complications since currently my own "autoloader" grabs ALL my js files and minifies them and combines them into ONE file for maximum caching and small filesize. If you are now autoloading my JS files then that means I will have to minify all my individual javascript which is quite a pain to do and much more time consuming when deploying new versions.

    Anyway maybe I got this all wrong.. please let me know.

  7. #7
    Sencha User
    Join Date
    Sep 2011
    Posts
    125
    Vote Rating
    0
    oddz is on a distinguished road

      0  

    Default


    Thanks for the information Jacky, it's appreciated. Though, sadly I've put this on hold going back to 1 because I am just running into way to many issues without the timeline to support them. thanks though… again.

  8. #8
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    oddz, could you please be more specific as to what kind of issues you are running into?

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