You need to sign in to do that
Don't have an account?
Page with one controller and RemoteAction on another
Hello,
I want to know (I can info about this) if I can have a Visualforce page with a controller and on that page a @RemoteAction with another controller, similar to this:
VISUALFORCE PAGE:
<apex:page standardStylesheets="false" docType="html-5.0" sidebar="false" showHeader="false" contentType="text/html" cache="true" controller="MyPageControllerClass"> <apex:composition template="TemplateFB"> <head> </head> <apex:form id="signUpForm"> <input type="text" name="Id" id="Id" /> <a href="#" onclick="javascript:signUp(); return false;">Click Me</a> <div id="processing"></div> </apex:form> <script> function signUp() { var str = ''; try{ str = document.getElementById('Id').value; }catch(e){} MyGlobalClass.SaveId(str , function(Result, event) { console.log('Result',Result); console.log('event',event); if (event.status) { document.getElementById('processing').innerHTML = 'Information updated.'; }else{ document.getElementById('processing').innerHTML = 'Problem!'; } }, {escape:true}); } </script></apex:composition></apex:page>
GLOBAL CLASS to manage @RemoteAction call:
global with sharing class MyGlobalClass { @RemoteAction global static String SaveId(string dataString) { String res = ''; MyPageControllerClass myc = new MyPageControllerClass(); try { res = myc.SaveRecord(dataString); } catch(exception e) { res = 'error'; } return res; } }
And my Controller on Visualforce page (and call exist a method called by the RemoteAction):
public with sharing class MyPageControllerClass { public String OneMethod(){ String t = 'one thing'; return t; } public String SaveRecord(){ String t = 'success'; return t; } }
With Chrome console I saw:
Uncaught ReferenceError: MyGlobalClass is not defined
:(
I need to use the code inside a iFrame.
I put on the "Sites" permission, all controllers available.
Anyone have idea if I can use a controller for the vf page and inside use @RemoteAction with another class?
Best Regards,
LB
Hello all,
The solution about this problem can found here:
http://boards.developerforce.com/t5/Apex-Code-Development/Different-controllers-to-VF-page-and-RemoteAction-is-possible/m-p/408941#M73684
Regards,
LB
All Answers
Hello,
Anyone have an idea about this?
Best Regards,
LB
Hello all,
The solution about this problem can found here:
http://boards.developerforce.com/t5/Apex-Code-Development/Different-controllers-to-VF-page-and-RemoteAction-is-possible/m-p/408941#M73684
Regards,
LB