View Full Version : How to call external controller from extjs4 application

8 Mar 2012, 6:01 AM
We have Application_1 --> controller_1 and Application_2 --> controller_2
How to call controller_1 from controller_2 in smvc .

Ext.application({ name: 'RuleObjectsApp',
autoCreateViewport: true,
appFolder: 'js/app/ruleobject/app',
controllers: [
........ more code

Ext.application({ name: 'FWPolicy',
appFolder: 'js/app/configure/firewall/policy/app',
autoCreateViewport: true,
controllers: ['FWPolicyController']
....more code

How to call RuleObjectsController from FWPolicyController ?



8 Mar 2012, 7:24 AM
This will work only if both Ext.Application objects are in scope, i.e. available in the same browser session. You can persist global references to each Application object.

In the launch function of your RuleObjectsApp config, you can do this:

launch: function() {
RuleObjectsApp.app = this;

Then do this in the FWPolicy app:

launch: function() {
FWPolicy.app = this;

You then will have two globally scoped Application object instances, where you can call controllers from either app, get views, execute functions, etc:


var data = FWPolicy.app.getController('SomeController').getSomeData();

8 Mar 2012, 8:24 AM
then we need to launch
RuleObjectsApp from FWPolicy right ? how do i achieve this ?

basically according to you we need communicate one app to another.

How to launch one app to another app in extjs4 ?


8 Mar 2012, 9:47 AM
I think the general design principal is that you have a single Ext.Application object which encompasses all of your app's functionality. I'd combine the two apps into one if possible/feasible.

If each app is already running separately within its own context on a server, what I suggested won't be possible.

You might be able to manually configure and load two separate Ext.Application objects in the same index.html page, but you'll have to try it and see. This would presume that the two apps are actually published in the same context on the server and that only one of the apps actually configures a Viewport, etc.

You're probably wasting your time trying to do this, but who knows? I've seen stranger things done before...