Activity Forums Salesforce® Discussions How to use two custom controllers in one Salesforce visualforce page?

  • Mohit

    Member
    September 21, 2016 at 2:01 pm

    Hi Tanu,

    You can have the two controller functionality in one visualforce page by using standard controller and extension. So in extension you can mention the name of multiple controller from which you want to access the functionality of these controller . For example:-

    VisualForce page:-

    <apex:page standardController="Account"
    extensions="ExtOne,ExtTwo" showHeader="false">
    <apex:outputText value="{!foo}" />
    </apex:page>

    Extension Class:-

    ExtOne:-

    public class ExtOne {
    public ExtOne(ApexPages.StandardController acon) { }

    public String getFoo() {
    return 'foo-One';
    }
    }

    ExtTwo:-

    public class ExtTwo {
    public ExtTwo(ApexPages.StandardController acon) { }

    public String getFoo() {
    return 'foo-Two';
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos