• #29726
    Salesforce | Sanjana Sanjana #17
    Forcetalks

    How many Controllers can be used on a single Salesforce visualforce Page?

    How many Controllers can be used on a single Salesforce visualforce Page?

     

    #29730
    Salesforce | suniti suniti #20
    Forcetalks

    Hi sanjana

    We can have only one controller at a time either it may be “StandardController” or custom Controller.And we can have as many as extensions we want.

    Thank you.

    #34092
    Salesforce | Parul Parul #2
    Forcetalks

    Hi,

    We can use two controllers on a single salesforce visualforce page. One is controller and for custom functionality, we can use Controller extension.

     

    Thanks.

    #34094
     Anjali #8
    Forcetalks

    Hi Sanjana,

    Only one controller can be used salesforce. Other than them, Controller extension can be used. There may be more than one Controller extension.

    Example-

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

    if ExtOne and ExtTwo, both have the method getFoo() then the method of ExtOne will be executed.

    #34111
    Salesforce | shariq shariq #1
    Forcetalks

    Hi,

    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’;
    }
    }

    Hope this helps!

    #34124
    Forcetalks

    Hello,

    You can use only one controller at a times but for extensions it depends on you.

    Thanks.

Viewing 6 posts - 1 through 6 (of 6 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?