function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Darshit Pathak 3Darshit Pathak 3 

How to call extension method in VF page when used with custom controller?

If my VF page already has custom controller. Now I am creating extension class with method getVal() , how can I call this extension method in my VF page?

Raj VakatiRaj Vakati
MOve the method in to the helper class and call that helper class logic in the  custom controller
Darshit Pathak 3Darshit Pathak 3
you mean to say that I have to call the extension method from custom controller only? like below
Directly I cannot call any extension method.. right? need to modify existing custom controller at least to call the extension method. Am I correct?

<apex: page controller="cont1" extensions="ext1">
<apex:outputText value="{!valCont}"/>
</apex:page>

public class cont1{
public static String getValCont() {
  return ext1.getValext();
}
}

public class ext1{
public static String getValext(){
return 'this is my extension class';
}
}
 
Raj VakatiRaj Vakati
Yes alomst .. like below

<apex: page controller="cont1" extensions="ext1">
<apex:outputText value="{!valCont}"/>
</apex:page>

Helper Class 

public class cont1{
public static  String  getValCont() {
return 'this is my extension class';

}
}
Extension 

public class ext1{
public String getValext(){
  return cont1.getValext();
}
}