You need to sign in to do that
Don't have an account?

global controller - apexpages.currentpage() returns null
I have a global with sharing controller which I'm using in VF page which uses JS Remoting. When I call ApexPages.Currentpage() or ApexPages.Currentpage().getParameters(), I'm getting null exception, anybody facing this issue ? is it a limitaion ?
Thanks
Ram
Hi ram,
where you can declare this in constructor? or directly in method?
Thanks
Its a global class with sharing and a global constructor,
following format:
//
global with sharing class dashboard{
global dashboard(){
}
@RemoteAction
global static List<Dashboard.Chart> doCalculations(){
//i'm callling apexpages.current page here, it returns null.
}
global class chart{
}
}
I think visualforce might assume since its a remot action method, this kind of web services method, no page associated with it, may be thats why I'm getting null.
Thanks
Ram
Did you manage to resolve this, Ram? I'm attempting to retrieve current user's ip address in a @RemoteAction method. For the same reason you stated ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP'); returns null.
I have an idea to hack it by storing the user's ip address in a hidden field when they first arrive on the page. I'd grab the ip address and pass it along in the remote call, but that isn't very elegant.
Is there no way to access the user's request headers/cookies in a remote call?
Thanks
When you say @remoteaction, I think visualforce assumes your request is async, so if its async there is no pagereference context available for that request. this is my reasoning. you might have to pass the params explicity to the method from client (javascript).
Thanks
ram
Pass the parameters in script on the page using {!$currentpage.parameters.parameter_name}
You will be able to again concatenate and use it in Apex though.