I am trying to use salesforce @RemoteAction with an action that is generic to a couple of other VF Pages (other vf pages will be calling the same action). So what I want to do is instead of creating duplicates of the same code for the @remoteAction, I am trying to have it as a separete class, that I can call it everytime I need it. My question is how to call it if the controller of the VF page is diferent to the remote class, for instance a VF page with remote will look like:
<apex:page controller="ChildRemoteController" >
<script type="text/javascript">
function sayHello(helloTo) {
ChildRemoteController.sayHello(helloTo, function(result, event){
if(event.status) {
document.getElementById("result").innerHTML = result;
}
});
}
</script>
......
</apex:page>
global with sharing class ChildRemoteController
extends ParentRemoteController { }
global virtual with sharing class ParentRemoteController
extends GrandparentRemoteController { }
global virtual with sharing class GrandparentRemoteController {
@RemoteAction
global static String sayHello(String helloTo) {
return 'Hello ' + helloTo + ' from the Grandparent.';
}
}
How can I have something to look like
<apex:page controller="OtherController" >
<script type="text/javascript">
function sayHello(helloTo) {
ChildRemoteController.sayHello(helloTo, function(result, event){
if(event.status) {
document.getElementById("result").innerHTML = result;
}
});
}
</script>
....
</apex:page>
I was trying something like
publi class OtherController {
public OtherController() {
ChildRemoteController crc = new ChildRemoteController();
}
}
global with sharing class ChildRemoteController
extends ParentRemoteController { }
global virtual with sharing class ParentRemoteController
extends GrandparentRemoteController { }
global virtual with sharing class GrandparentRemoteController {
@RemoteAction
global static String sayHello(String helloTo) {
return 'Hello ' + helloTo + ' from the Grandparent.';
}
}