JavaScript remoting can be used in Visualforce to call methods in Apex controllers from JavaScript.
Moreover, it helps in creating pages with complex, dynamic behaviour that isn’t possible with the standard Visualforce AJAX components.
3 things to be implemented while using JavaScript Remoting
- Remote Method Invocation you add to the Visualforce page, written in JavaScript
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.controllerName.methodName}',
[parameters...,],
callbackFunction,
[configuration] );
}
- Remote Method Definition in your Apex controller class
@RemoteAction
[public,global] static [ReturnType..] methodName([parameters...,]) {
//... return [ReturnType..];
}
- Response Handler Callback Function you add to or include in your Visualforce page, written in JavaScript
callbackFunction(result, event){
//...
}
No comments:
Post a Comment
Thank you for visiting. Your comments are highly appreciated.