View Full Version : Controller Action ordering and chaining

27 Feb 2013, 9:14 AM
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?

1 Mar 2013, 7:59 AM
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.

1 Mar 2013, 8:46 PM
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.

// ... in init()
'#myButton': {
click: this.onButtonClick

onButtonClick: function (btn) {
// this.getController('ControllerTwo').handleButtonClick(btn); // as needed
// this.getController('ControllerThree').handleButtonClick(btn); // as needed

1 Mar 2013, 9:25 PM
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.