1. #11
    Sencha User
    Join Date
    Mar 2010
    Posts
    1
    Vote Rating
    0
    tellurion is on a distinguished road

      0  

    Default


    Quote Originally Posted by marzapower View Post
    Probably the real question is: how can I access the instance of my application?
    Could I access it, I would be able to reach its inner 'controllers' parameter, and probably it all will work correctly ...
    Every controller has a reference to the application called....application.
    So, inside your controller you can use: this.application.getController('controllerName')
    This will create an instance of the controller if one doesn't exist. If that is not what you
    want, then use: this.application.controllers.get('controllerName')

    -Scott

  2. #12
    Ext JS Premium Member
    Join Date
    Mar 2009
    Location
    San Mateo, CA
    Posts
    32
    Vote Rating
    3
    bergstyle is on a distinguished road

      0  

    Default


    Let's say your somewhere else in the application, like handling an exception from an ajax call because the user is not logged in. If I want to call a method in my Auth controller to display a login form only thing that works (so far) is steffenk's approach.

    PHP Code:
    App.controller.Auth.prototype.showLoginForm() 
    Seems like there would be a better solution for handling these type of Application level events that aren't attached to visual components. Has anybody found a better solution?

    It looks like Ext.app.EventBus.dispatch could be a solution but from what I could tell its expecting selectors.

  3. #13
    Sencha User
    Join Date
    Jul 2010
    Posts
    15
    Vote Rating
    0
    marzapower is on a distinguished road

      0  

    Default


    Quote Originally Posted by bergstyle View Post
    Let's say your somewhere else in the application, like handling an exception from an ajax call because the user is not logged in. If I want to call a method in my Auth controller to display a login form only thing that works (so far) is steffenk's approach.

    PHP Code:
    App.controller.Auth.prototype.showLoginForm() 
    Seems like there would be a better solution for handling these type of Application level events that aren't attached to visual components. Has anybody found a better solution?

    It looks like Ext.app.EventBus.dispatch could be a solution but from what I could tell its expecting selectors.
    Well, calling a prototype directly is not a good solution, in my opinion ... I'd rather be able to call the controller instance directly.
    To accomplish this, the only solution I've found is establishing an asynchronous messaging mechanism, so that each controller subscribe itself to a particular message, and when this message is published on the common bus by another component a callback is fired. This approach has the advantage of decoupling very well the controllers, giving more flexibility to the whole architecture.

    I can give you more information about this. But if you found a different, better, approach, I will be glad to look at it!

  4. #14
    Ext JS Premium Member
    Join Date
    Mar 2009
    Location
    San Mateo, CA
    Posts
    32
    Vote Rating
    3
    bergstyle is on a distinguished road

      0  

    Default


    marzapower, I'd be interested in learning more about your message bus implementation. I remember seeing a message bus solution floating around for Ext 3 but I haven't seen anything like that for 4.

  5. #15
    Sencha User
    Join Date
    Jul 2007
    Posts
    33
    Vote Rating
    1
    yd290276 is on a distinguished road

      0  

    Default


    Hello,
    i'm in the same way of approach whit message bus. My problem is that i want to completely decouple controllers because i have an application architecture that is not aware of wich controller is instanciated at a time because of i use dynamic loading and instanciation.

    So i need a message bus system, but there is none is ExtJS 4.X. In extJS 3.X there was a message bus in ux packages, but it doesn't work in ExtJS 4.X.

    Can you tell us more on your message bus implementation ?

    Thank you !

  6. #16
    Ext JS Premium Member
    Join Date
    Mar 2009
    Location
    San Mateo, CA
    Posts
    32
    Vote Rating
    3
    bergstyle is on a distinguished road

      0  

    Default


    hey yd, for the time being I decided to go with the approach I outlined here (using application events). It's pretty light-weight and seems to work well until a more solid message bus becomes available.

  7. #17
    Sencha User
    Join Date
    Jul 2007
    Posts
    33
    Vote Rating
    1
    yd290276 is on a distinguished road

      0  

    Default


    humm, i understand your implementation but that require the controllers are aware of application and subscribe to events that are "hard coded".
    In addition, if i want two controller to "communicate" i can't use your solution because it would involved application MUST be aware of what events it should fire.

    What i want is one controller subscribe to an event (says 'do_something') and another controller fire the event 'do_something').

    Do you know if the class Ext.app.EventBus could achieve this requirements ?

    thanks !

  8. #18
    Sencha User
    Join Date
    Aug 2008
    Posts
    49
    Vote Rating
    7
    TonySteele is on a distinguished road

      0  

    Default


    You might like to look at this message bus

    http://developer.tibco.com/pagebus/default.jsp

    I have been using it for several years with ExtJS

  9. #19
    Sencha User
    Join Date
    Jul 2007
    Posts
    33
    Vote Rating
    1
    yd290276 is on a distinguished road

      0  

    Default


    Hello !

    Great message bus system. It would be amazing ExtJS team implement same "tools" in the framework.
    Maybe i'll post a feature request for this as it is a very usefull tool for all ajax developper !

    Waiting for extJS to be able to implement message bus system, i'll use these from tibco.

    Thank you for your help !

  10. #20
    Sencha User
    Join Date
    May 2011
    Posts
    4
    Vote Rating
    1
    jimprotos is on a distinguished road

      0  

    Default Global access to the application instance

    Global access to the application instance


    maybe this comes in too late, but anyway ...

    on 4.1.0 version you can instantiate your app like that:

    Code:
        var myApp = Ext.app.Application.create({
            name: 'MyApp',
            
            autoCreateViewport: true,
            
            models: [...],    
            stores: [...],
            controllers: [...]
        });
    and then access a controller :

    Code:
    myApp.getControllers('controllerName').methodName
    Hope this helps...

Similar Threads

  1. GET, PUT and POST for the COntroller
    By PCD in forum Ext Designer: Help & Discussion
    Replies: 4
    Last Post: 7 Apr 2011, 2:18 AM
  2. [ZEND Framework + ExtJS 3] Sending data to the Controller
    By Raqil in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 24 Jul 2010, 3:59 PM
  3. BadRequest Error while sending long Parameter to controller methods
    By henryivy in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 7 Aug 2009, 6:04 AM
  4. View, Controller and RPC
    By sdc in forum Community Discussion
    Replies: 2
    Last Post: 13 Dec 2008, 3:46 AM
  5. Controller in CodeIgniter can't read param sending from Ext.grid.GridPanel
    By shuchanlagi in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 14 Aug 2008, 12:09 AM

Thread Participants: 6

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar