3

i have created visualforce page with multiple extension.

For ex: for controller one(cntrl1) i have created method(methd1) and for controller two (cntrlr2) i have created same method(methd1). Now on button click in visualforce page i want to call methd1 from cntrlr2. How i can achieve this?

  • 1
    It is important what extension is defined first, bacause it overrides the same methods from all other extensions: Overrides are defined by whichever methods are defined in the “leftmost” extension, or, the extension that is first in the comma-separated list. Learn more about extensions: Building a Controller Extension – Sergej Utko Oct 23 '13 at 7:28
  • Sorry mast0r we have the same answer, didn't see your comment – Cloud Ninja Oct 23 '13 at 8:03
5

You can not really control which action you want to call. The first class in your extensions will have always the highest priority : doc here.

//it will always call method from cntrlr1 first
<apex:page standardController="Contact" extensions="cntrl1,cntrlr2">

//it will always call method from cntrlr2 first
<apex:page standardController="Contact" extensions="cntrl2,cntrlr1">

Better for you if you change the name of your methods.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.