Results 1 to 4 of 4

Thread: Controller Action ordering and chaining

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2011
    Posts
    20
    Answers
    1
    Vote Rating
    2
      0  

    Default Controller Action ordering and chaining

    Is there a means to determine and/or set the order of which controller actions will run. For example, lets say that I have 3 different controllers each handling the save button click. Ideally, I would like them to run in a particular order given the nature of their activities and ensure that processing stops if the first one fails. Can this scenario be handled with the native MVC pattern in place today or do I need to implement my own pattern to support such a case?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,381
    Answers
    3997
    Vote Rating
    1536
      0  

    Default

    Haven't tried it but the order of the controllers will probably be based on the order of controllers array in Ext.application and the action order based on the order in the this.control call.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    255
      0  

    Default

    Just throwing this out - what if you had a 'common' controller that did the listening for the click event and then pointed to the handlers in whatever order/business logic you wanted.

    Code:
    // ... in init()
    this.control({
        '#myButton': {
            click: this.onButtonClick
        }
    });
    
    onButtonClick: function (btn) {
        this.getController('ControllerOne').handleButtonClick(btn);
        // this.getController('ControllerTwo').handleButtonClick(btn); // as needed
        // this.getController('ControllerThree').handleButtonClick(btn); // as needed
    }

  4. #4
    Sencha Premium Member
    Join Date
    Aug 2011
    Posts
    20
    Answers
    1
    Vote Rating
    2
      0  

    Default

    Thanks for the responses. @mitchell - the challenge I have is that I won't know the order in which the controllers will be declared because I'm not doing this in a non conventional way. I am building a rails based framework that has separate functional components in dedicated gems. Much like Sencha tools, I'm leveraging the rails asset pipeline to bring the disparate features into a single JS app.

    Additionally, I was hoping to have the capability where I could disable an action from a different class without directly changing the source. I have considered adding this capability if it cannot be solved natively - but would take a workaround in the near-term to avoid backtracking too much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •