Tell me more ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Hi can anybody guide me how to call a method in controller from a VF page.

share|improve this question

2 Answers

There are two methods to do this :

1)Use @Remote Action Call to call the method

2)Use ACtion Function and call on the event

Here are the documentations for the same

http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm

Video of demo sessions

https://www.youtube.com/watch?v=ckkChgcM9VQ

Summary :Use actionfunction if you need to maintain state between postbacks, remoteaction for stateless invocations

share|improve this answer
2  
Use actionfunction if you need to maintain state between postbacks, remoteaction for stateless invocations. – Bob Buzzard Nov 29 '12 at 12:57
@BobBuzzard Perfect Bob!!Thanks – Mohith Kumar Nov 29 '12 at 13:33

Apex method:

public PageReference getMyMethod(){
    ....
    return null;
}

Visualforce page action function:

<apex:actionFunction action="{!MyMethod}" name="myFunction" />

actionFunction works like a javascript function, so you can call it from anywhere at your page like this:

<apex:inputField value="{!something}" onchange="myFunction()" />
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.