1. #1
    Sencha User Fire-Dragon-DoL's Avatar
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9
    Vote Rating
    1
    Fire-Dragon-DoL is on a distinguished road

      0  

    Default Answered: Modifying a view that belongs to another controller

    Answered: Modifying a view that belongs to another controller


    I have a desktop-like application which has 2 controllers: 'Desktop' which represents desktop icons and 'Taskbar' which represents the taskbar where you find buttons to minimize/restore windows already opened, like MS Windows is working.
    The problem I currently have is the approach to "how should I display the window". Infact after doubleclicking the icon, I should create a window, and this could happen both on Desktop controller or on Taskbar controller (or maybe directly on the viewport, because they can be dragged anywhere). However, when I create a window, a new button should be created on the taskbar to minimize/restore it.
    Because of this, I thought about handling window in the taskbar controller, however I don't know how to reach the Taskbar controller from the Desktop controller.
    I have 3 ideas in my mind at the moment:
    1. The Desktop controller directly adds the button to the TaskbarView, but in this way I'm feeling like violating MVC pattern. Also I need to specify TaskbarView in Desktop views.
    2. The Desktop controller after icon doubleclick fires a custom event on the Taskbar controller. In this case the taskbar opens the windows and adds the button, this approach is quite linear but I don't know how to reference a controller from another controller (in this case, from Desktop to Taskbar)
    3. The Ext.Application register for itemdblclick event on Desktop controller. When this event is fired, it redirects (or call a custom event) on Taskbar controller. After this everything keeps going like point 2. In this way I centralize the Routing functionality (like rails), however could also happen that Application object becomes really big. Also I'm using it as a "gigant controller" to route everything, but this is not really a big problem, thinking about rails it does something similar.
    4. The application should not be split in 2 controllers (so Desktop and Taskbar should be one) and everything will be fine. I don't think this approach is correct.
    So, my questions are:
    • Which approach should I use: 1,2,3,4 (or specify if there is something different)?
    • What a window should belongs to: Desktop controller, Taskbar controller, something else?
    Thanks for any answer

  2. if you are following the ext js mvc pattern, you are creating one application (which is an extension of the controller class -> the main controller) and other subcontrollers.

    in your controller's scope you can access:
    Code:
    this.application
    and you can go for:
    Code:
    this.application.fireEvent(...);
    or

    Code:
    this.application.getController(...);
    it depends on which way you prefer to go. firing events on the main controller is a bit cleaner (messagebus way) and it might be better to maintain, in case you are using your controllers in multiple apps and can not guarantee that the one you directly access is always there.

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,681
    Answers
    130
    Vote Rating
    112
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    if you are following the ext js mvc pattern, you are creating one application (which is an extension of the controller class -> the main controller) and other subcontrollers.

    in your controller's scope you can access:
    Code:
    this.application
    and you can go for:
    Code:
    this.application.fireEvent(...);
    or

    Code:
    this.application.getController(...);
    it depends on which way you prefer to go. firing events on the main controller is a bit cleaner (messagebus way) and it might be better to maintain, in case you are using your controllers in multiple apps and can not guarantee that the one you directly access is always there.
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

Thread Participants: 1

Tags for this Thread