+ 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();
}
}