How do you call one controller method from another?

How do you call one controller method from another?

Yes, you can call a method of another controller. The controller is also a simple class. Only things are that its inheriting Controller Class. You can create an object of the controller, but it will not work for Routing if you want to redirect to another page.

How do you call a method in controller class?

Calling a DAO method from a controller class

  1. In your controller class, add the DAO as an @Autowired field: @Controller public class UserController { @Autowired private UserDAO userDAO;
  2. Use the DAO in any controller method: userDAO. add(user);

How do I call a method from another class in the same package?

If it’s not static , then you need an instance of the class on which to call it: TheClass t = new TheClass(); t. theMethod(); Note that to use a method of a class from an unrelated class in the same package, the method must not be marked private .

How to call a controller action from another controller?

I would encapsulate the logic you want to call in separate class, then simply instantiate the class and call it. Controllers should be a light weight implementation ideally calling functionality that lives in your model or a separate layer, so you should never need to call one action from annother action.

How to call a method of a class into another?

How to call a method of a class into another… I want to use a method of a class onto another class. I want to use method1 in class controller2. Please help me to find the solution on it. Please log in or register to add a comment. Please log in or register to answer this question. 1. Using Static methods:

When to call controller from another controller in Odoo?

The below issue raises when we are trying to call one controller class method that is inherited from some another controller class, from another controller class in Odoo. For example we have two controllers with class name InheritedHome and MyCustomClass.

Can you use another controller in ASP.NET?

.net controller using another controller? Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper ‘-jvm-target’ option