Extensions having same method name

    If Extensions are having same method name, it gets overridden.
    Overrides are defined by whichever methods are defined in the “leftmost” extension, or, the extension that is first in the comma-separated list.

Apex Page:

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


Extensions:


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

    public String getStr() 
   {
        return 'Str-One';
    }
}

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

    public String getStr() 
   {
        return 'Str-Two';
    }
}


    The value of the <apex:outputText> component renders as Str-One. Overrides are defined by whichever methods are defined in the “leftmost” extension, or, the extension that is first in the comma-separated list. Thus, the getFoo method of ExtOne is overriding the method of ExtTwo.

Cheers!!!

No comments:

Post a Comment