You need to sign in to do that
Don't have an account?
Sonali Mhatre 1
Unable to call Controller Extension's method from VisualForce page
I want to call a method from controller extension on the onfocus event from Visualforce Code.My Controller Extension method has a System.debug statement. The following debug method call is not displayed in the Developer Console.
Visualforce Code where call to Controller Extension's method is made:
<apex:inputField value="{!SomeLookupField}" onchange="getMethod()"/>
Controller Extension Code:
public PageReference getMethod()
{
System.debug('inside method getMethod()');
}
I tried to refer to several posts on the developer forum but it does not seem to work still.
Can you please suggest on this?
Visualforce Code where call to Controller Extension's method is made:
<apex:inputField value="{!SomeLookupField}" onchange="getMethod()"/>
Controller Extension Code:
public PageReference getMethod()
{
System.debug('inside method getMethod()');
}
I tried to refer to several posts on the developer forum but it does not seem to work still.
Can you please suggest on this?
<apex:inputField value="{!SomeLookupField}" onchange="getMethod()"/>
in above tag onchange is a javascript event.
So directly we cant call controller methods from javascript.
so instead of that we will use actionsupport or action function.
plz check sample code below
please let me know if you have any questions
Thanks
Varaprasad
Thanks for your suggestion.
I tried the way you told. When I select the value from lookup field on Visualforce Page, the log generates on Developer Console but it doesn't show the debug statement. Even after adding a filter it does not display the debug statement.
Visualforce Code where call to Controller Extension's method is made:
<apex:inputField value="{!SomeLookupField}">
<apex:actionSupport action="{!getMethod}" event="onchange" reRender="DsptDtls"/>
</apex:inputField>
Controller Extension Code:
public PageReference getMethod()
{
System.debug('inside method getMethod()');
}
Can you please help me on this?
please check once your debuglog level settings.
In above examples check second one it is working.
thanks
varaprasad
As per your suggession I checked my debug settings and they are as per you specified but still I am stuck on the same problem.
Can you please take a look into my code? Let me know if any changes required in code.
Visualforce Code where call to Controller Extension's method is made:
<apex:inputField value="{!SomeLookupField}">
<apex:actionSupport action="{!GetMethod}" event="onchange" reRender="DsptDtls"/>
</apex:inputField>
Controller Extension Code:
public PageReference getMethod()
{
System.debug('inside method getMethod()');
}
Thanks,
Sonali.
check the example below.
http://salesforceglobe4u.blogspot.com/2017/05/actionfunction-in-salesforce.html