Skip to content

Instantly share code, notes, and snippets.

@futurehope
Created May 16, 2012 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save futurehope/2713502 to your computer and use it in GitHub Desktop.
Save futurehope/2713502 to your computer and use it in GitHub Desktop.
Visualforce.remoting.Manager.invokeAction bring used correctly? 0,1,2 works in spring12, only single argument works in summer 12 with new method
global class RemoteController {
@RemoteAction
global static String test0Str(){
return '0 arguments';
}
@RemoteAction
global static String test1Str(String str){
return str;
}
@RemoteAction
global static String test2Str(String str1,String str2){
return str1+ ' ' + str2;
}
}
<apex:page controller="RemoteController" >
<script>
function handleReturn(result, event) {
if (event.status) {
document.getElementById("output").innerHTML = result + ', ' + document.getElementById("output").innerHTML;
} else if (event.type === 'exception') {
document.getElementById("output").innerHTML = event.message;
} else {
document.getElementById("output").innerHTML = event.message;
}
}
</script>
<div id="output" />
<form >
<div>
<input value="summer12 0 params" onclick="Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.RemoteController.test0Str}', handleReturn,{escape: true})" type="button" />
<input value="spring12 0 params" onclick="RemoteController.test0Str( handleReturn,{escape: true})" type="button" />
</div>
<div>
<input value="summer12 1 params" onclick="Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.RemoteController.test1Str}','1 argument', handleReturn,{escape: true})" type="button" />
<input value="spring12 1 params" onclick="RemoteController.test1Str('1 argument', handleReturn,{escape: true})" type="button" />
</div>
<div>
<input value="summer12 2 params" onclick="Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.RemoteController.test2Str}','2','arguments', handleReturn,{escape: true})" type="button" />
<input value="spring12 2 params" onclick="RemoteController.test2Str('2','arguments', handleReturn,{escape: true})" type="button" />
</div>
</form>
</apex:page>
@joshdance
Copy link

Answer here - https://developer.salesforce.com/forums?id=906F000000097yIIAQ, multiple parameters do work. It was a bug, might have been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment