You need to sign in to do that
Don't have an account?
Dipak
How to use More Than one controller class in a single VF page
Hi,
Can i use multiple controller class in a single VF page. My Vf page dont have standardcontroller , i want to use only two or more user defined controller class. Is it possible, please let me know about its syntax or solutions.
I don't think you can specify multiple custom controllers that way - the docs say that the controller attribute takes one class name.
You can, however, use extensions with custom controllers in the same way as standard controllers, e.g.
Your extensions will need to have constructors that take an instance of the custom controller as a parameter.
All Answers
It is possible to use more than one controller class. You can use "Extensions"
This link contains an example of how to use Extensions with Standard controller. You can use it in a similar way with an ordinary Controller as well. [You cannot use a controller if you are using a standard controller and vice versa]
Hope this helps!
Hi Shruti,
In the exmample, a standard controller is used. But i dont want to use any standard Controller. Can i use controller instead of standardController? I have also tried that one, But in that case, the extension Controller class Constructor takes the Controller class object as its parameter. I dont need that one. My two controller classes are independent with each other.
If there is any other solution, please let me know
u can use like this controller="class1,class2........"
I don't think you can specify multiple custom controllers that way - the docs say that the controller attribute takes one class name.
You can, however, use extensions with custom controllers in the same way as standard controllers, e.g.
Your extensions will need to have constructors that take an instance of the custom controller as a parameter.
Thanks Bub,
You are absolutely right. Thanks a lot for your suggestion.
If i am not going to use the constuctor of extension controller having parameter as controller class instance, then it is not possibel to achieve that one.
So i used one controller class, and from that controller , another class method(i.e the 2nd controller) is called.
After that my code is working perfectly..
Thanks all for your help
ya sorry i mistakely right the above post... ya its extension where you can give more than one class....