You need to sign in to do that
Don't have an account?

Call Controller method in visualforcecomponent
Hi guys,
Can anyone please provide me an example on how to call a apex controller method in a visualforce custom component using a command button?
Can anyone please provide me an example on how to call a apex controller method in a visualforce custom component using a command button?
You can call controller method on click of command button by using action attribute
here is the code:
VF Component
Controller code:-
Thanks,
Atul patil
salesforce developer
www.zen4orce.com
All Answers
You can call controller method on click of command button by using action attribute
here is the code:
VF Component
Controller code:-
Thanks,
Atul patil
salesforce developer
www.zen4orce.com
You can call apex controller method from command button by following ways -
1. You can use action attribute of command button to call apex controller method
For example - 2. You can use action function too. Visit this link for more details and example https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionFunction.htm?search_text=apex:actionfunction
Hope you find this helpful.
Note - Kindly mark this answer as best answer if this helped you, so that other's can also get benefit from it.
Thanks,
Mustafa Jhabuawala
Technical Lead at Zen4orce (http://www.zen4orce.com)
You can controller method in diffrenet way
1 Using CommandButton with action attribute
in action attribute specify your controller method like
<apex:commanbutton value="XYZ" action="{!yourControllerMethod}"/>
2 Using action functon
<apex:commandButton value="XYZ" onclick="callMethod()"/>
<apex:actionFunction id="setState" action="{!yourControllerMethod}; return false;" name="callMethod" />
using action fuction you can pass parameter to controller
3 Using action support
</apex:outputpanel>
<apex:outputText value="Enter Value"/>
<apex:actionSupport event="onclick" action="{!yourControllerMethod}"/>
</apex:outputpanel>
Thank you,
Amol Salve
Salesforce Developer