-
8 Jun 2011 9:57 AM #1
How to reference a controller's method?
How to reference a controller's method?
I know this could be a really trivial question...
I'm a ExtJS 3.x user and I'm trying to upgrade to 4.0, using MVC.
How can I reference (call) one controller's method, from another controller (or from inside app.js)?
I read the MVC tutorial, but I cannot find it.
Many thanks.
Erik
-
8 Jun 2011 10:22 AM #2
Good question.
I'm using MVC but still dont understand how it works behind the scenes.
For example, I made a view and controller to edit some entity.
From other controller I instantiate the view and VOALA! the controller "takes control" of the new view which is a modal window BTW.
How this is done?
Still a mistery to me!
Regards.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
8 Jun 2011 12:56 PM #3
I will try to undestand what's going behind the scenes when I understand a little more the basics...

For example, if I have 2 classes, say APP.controller.User and APP.controller.Profile, how can I call the method "getUserDetails" (located in the first controller) from the controller APP.controller.Profile?
-
8 Jun 2011 3:16 PM #4
There is a method called getController() in Application and in Controller (which delegates to application instance) which looks for controller inside app and if doesnt exists creates it.
May be you can use such method but as I said, I have no clue how plumping between views and controllers works (I think controller discoveres refs looking thru all DOM).
So, to call a method from one controller to another should be something like
It seems that only one instance of each declared controllers exists in the application.PHP Code:var controller = this.getController("othercontrollername");
if (!controller) {
// Something went bad...
} else {
// Call the method
controller.someMethod();
}
Regards.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
9 Jun 2011 4:11 AM #5
-
5 Dec 2012 1:51 PM #6
yourappname.app.getyourcontrollerjscalssController().methehodname()


Reply With Quote