You found a bug! We've classified it as a bug in our system. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,664
    Vote Rating
    7
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default [CLOSED][B1] MVC pattern doesn't work correct

    [CLOSED][B1] MVC pattern doesn't work correct


    The main problem is the controller. Starting from main application, it's not possible to use the controller in require like.


    Code:
    Ext.require({'namespace.controllers.Index'});
    The error fiven is
    Uncaught Error: [Ext.Loader] The following classes are not declared even if their files have been loaded: 'namespace.controllers.Index'. Please check the source code of their corresponding files for possible typos: 'namespace/controllers/Index.js'
    I quote the comment from nickname here:
    can not load the controller this way, because it is defined with Ext.regController
    possible, if defining controllers with Ext.define (but thats not an option)
    and then the next problem is, that that we do not want to name the controller with the
    complete namespace (namespace.controllers.Index), but just name the controller to "Index"
    is an other problem: double use of names and Ext.require() can not find the file
    I can confirm this while testing.

    Additionally nickname has commented some notes which are very valuable:
    /**
    * Example Controller
    *
    * Try to render the Index/Index view, not business logic at the moment.
    *
    * In the action render() is called to render the view in the viewport.
    * In Sencha Touch demos it is used like:
    * this.render('registered_name_of_view', { options: like_listeners })
    * To do so, we need to Ext.reg() the view, but this is not an option in ExtJs4.
    *
    * Using "alias" in the definition of the view and then render() does find the view.
    * But the docs are wrong!
    * Ext.Controller::render() says:
    * render( String viewName, Object config) : Ext.View
    *
    * First Parameter "viewName": should be a String
    * Problem : In the Ext.Controller::render() method a string will not work
    * Source:
    * /**
    * * Renders a given view based on a registered name
    * * @param {String} viewName The name of the view to render
    * * @param {Object} config Optional config object
    * * @return {Ext.View} The view instance
    * *\/
    * render: function(config, target) {
    * var Controller = Ext.Controller,
    * application = this.application,
    * profile = application ? application.currentProfile : undefined,
    * profileTarget, view;
    *
    * Ext.applyIf(config, {
    * profile: profile
    * });
    *
    * view = Ext.createByAlias(config.xtype, config);
    * .............
    * => config needs to be an Object, so that Ext.applyIf() can work and than in the last line
    * config.xtype can be accessed!
    *
    *
    * Second Parameter "target": Docs says: Config Object
    * Source (extends the above source snippet)
    * if (target !== false) {
    * //give the current Ext.Profile a chance to set the target
    * profileTarget = profile ? profile.getRenderTarget(config, application) : target;
    *
    * if (target == undefined) {
    * target = profileTarget || (application ? application.defaultTarget : undefined);
    * }
    *
    * if (typeof target == 'string') {
    * target = Ext.getCmp(target);
    * }
    *
    * if (target != undefined && target.add) {
    * .........
    *
    * => The second parameter is "target" to render the named view to.
    * In this example no use of "profiles" (but even setting one wasnt successfull)
    * In the controller render({xtype: 'view_name'}, 'TARGET_VIEWPORT_NAME') is used.
    * The sources suggest, that if no renderTarget is defined it gets the renderTarget from
    * th application (application.defaultTarget). But defaultTarget is nowhere documentated
    * and it is just used one time (here), grepping the sources shows
    * lib/Ext/src# fgrep -rnH defaultTarget *
    * Controller.js:372: target = profileTarget || (application ? application.defaultTarget : undefined);
    * lib/Ext/src#
    *
    * This seems to be something "old" from Sencha Touch (it is used there) or not implemented in ExtJs4.
    *
    * Next problem with the target: if defining the Viewport with Ext.define('nam_of_viewport, {options: obj})
    * and "init" the Viewport in Application with Ext.create/Ext.widget the Viewport Component is not an instance of
    * Ext.container.Viewport, just an Ext.Base.
    * Not if we want search and find the target component and it is checking if there is a "target.add" method
    * it will not work. Ext.base does not have an .add() method.
    * ==> Workaround: init the viewport directly in the application definition and manually set application.defaultTarget!
    * From application: defaultTarget: "main" (config option, id has to be set in the tabpanel configuration)
    * Then use the ID of the Viewport/Panel as target name
    *
    * So, rendering just works if a target is defined, but just setting target to true (this.render(configobj, TRUE)) does not work.
    * To determine the renderTarget from the application the target needs to be set to "undefined".
    * Now the renderTarget is located from application definition. Both ways work
    *
    *
    * Third problem with the docs of render(): Docs say: "Return Ext.View". Ext.View does not exists in ExtJs4!
    *
    *
    * Now the View should be rendered in the Viewport (Tabpanel of center region). But the TabPanel does not switch
    * the active Tab. In the sources (again in Ext.Controller::render():
    *
    * if (target.layout && target.layout.setActiveItem) {
    * target.layout.setActiveItem(view);
    * }
    *
    * This works for the TabPanel Body, but not for Tab in the TabPanel. Manually setActiveTab() (lazy grab the Cmp, not good)
    */
    Please find the complete example in this post:
    http://www.sencha.com/forum/showthre...s-need-support
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

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

      0  

    Default


    Hi,

    i like to push this issue. The MVC is a really fantastic key feature, and it was presented by Ed along with app structure.
    Unfortunally there is no working example, and we are trying to get it work. but without proper documentation we are doing this in try&error mannar, reading core source, analyse etc.
    Please could someone look into this thread where many question arise, we definitive need some help and support, as it takes as double of time to get these question answered:
    http://www.sencha.com/forum/showthre...s-need-support

    At the end we all want to write real applications and not only flat pieces of code, so this is a real important aspect changing the coding style with Ext4, thanks!
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  3. #3
    Ext JS Premium Member
    Join Date
    Oct 2009
    Posts
    29
    Vote Rating
    3
    iesdeveloper is on a distinguished road

      0  

    Default


    +1 support

    I would really like to see a full-fledged working example using the Ext JS 4 MVC architecture. It looks really exciting, but right now without adequate examples/docs were just stumbling around in the dark.

    For our company at least, this is actually a higher priority than most of the minor cosmetics/bug fixes, since it impacts the high-level design the new apps we're building in ExtJS 4.

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Yeppers!

    Regards,
    Scott.

  5. #5
    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 release after beta 2 will contain some massive improvements and fixes to the MVC package, and a good MVC example will be included.

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

      0  

    Default


    Tommy, does that mean we have to wait until beta3 until we can start with MVC?
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  7. #7
    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


    I would suggest doing so yes

  8. #8
    Ext JS Premium Member
    Join Date
    Oct 2009
    Posts
    29
    Vote Rating
    3
    iesdeveloper is on a distinguished road

      0  

    Default


    Tommy,

    Thanks for clearing that up.

    Not exactly what we wanted to hear , but gives us some guidance.

    We'll defer trying to grasp the MVC stuff until it's more fleshed out in later releases, and focus instead on designing apps the "old-fashioned" way for a bit longer.

  9. #9
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Cologne, Germany
    Posts
    27
    Vote Rating
    0
    jan.harmsen is on a distinguished road

      0  

    Default backbone.js - a lightweight JavaScript MVC framework

    backbone.js - a lightweight JavaScript MVC framework


    just a two-liner for people being in despair of the current ExtJS MVC package state and urgently needing something that works out of the box:

    I found relief in the form of backbone.js, a lightweight JavaScript MVC framework. It is possible to use backbone.js for the Model / Controller part and use ExtJS widgets for the View part only.

    http://documentcloud.github.com/backbone/

    There is even a working CouchDB connector for backbone: https://github.com/janmonschke/backbone-couchdb


    @Sencha Dev team:
    THANKS for informing your (paying) customers about the situation.
    Still looking forward to a release that can be used in production.

    Best regards,

    Jan

Similar Threads

  1. Replies: 2
    Last Post: 5 May 2010, 9:10 AM
  2. [CLOSED]Store's getById() doesn't work correct
    By t800t8 in forum Ext 3.x: Bugs
    Replies: 7
    Last Post: 30 Sep 2009, 2:39 AM
  3. Replies: 4
    Last Post: 2 Jun 2009, 9:21 AM
  4. Replies: 2
    Last Post: 13 Oct 2008, 6:18 AM
  5. [2.2][OPEN] History Example doesn't work correct
    By KimH in forum Ext 2.x: Bugs
    Replies: 4
    Last Post: 7 Aug 2008, 11:52 AM

Thread Participants: 4