You need to sign in to do that
Don't have an account?
an answer required for an interview question
Hi
I was facing a telephonic round of an interview and the interviewer had asked me this question.. I tried to ask people working for over 2 years on salesforce and a team Lead as well but couldn't find the answer.. So here I am.. where I've always got the help, when looked for.. So here Is the Question
Int: can we use use Multiple extensions?
Me: Yes, we can.
Int: we have three extensions ext1, ext2, ext3.. and all of them have the method Method1.. and I call this method in a VFPage whose method will be called..
Me: The one which is on he left most side.
Int: I want to call the Method of Ext2/Ext3.. How will I do so?
Me: Numb!! Job Gone!! Me yet Jobless.. :(
Hi,
You can achieve this using javascript.
http://salesforce.stackexchange.com/questions/12747/calling-extension-methods-from-javascript
If you have defined a standardController="Account" on page and extensions="Class1, Class2, Class3". Now you use a action={!save} on page.
1. Assuming that none of the class is having this save method. So page will automatically call the StandardController's save method.
2. If Class 1 has save method, that will be called first.
3. Class 1 doesn't have, but Class 2 has, that will be called.
4. Class 1 and 2 don't have, but Class 3 has, that will be called.
5. if someone want to call a method from Class2, don't need to define that on Class1.
But what if the save is defined on all class1, class2 and class3.. and then I had to choose the class from which I want to cal it from ... then how could that be achieved??
If you want to call the class2 save method, you will have to do it from class1 save method.
If you have method's of same name in all of your extenssions then one in the left side class will be called default.
Thanks,
One way to accomplish this would be to design the first extension method to conditionally call another extension's method.
For example:
The first extension:
The second extension:
The page:
If you load this page without an account id on the query string, it displays "No ID specified".
If you load it with the ID of an account named "Pyramid Construction Inc." it displays that name.
If you load it with the ID of an account NOT named "Pyramid Construction Inc." it displays "This is not Pyramid Construction Inc.."
(The question of whether or not this is good object-oriented design is a whole other topic.)