You need to sign in to do that
Don't have an account?
System.currentPageReference() returns null
Hi All,
I'm developing simple VF page to edit one of my custom objects and for that I'm using an apex extension. In the extension, I'm refering to
System.currentPagereference().getParameters().get('Id');
to query the relevent record. But it's saying am trying to refer a null object. When I do drill down the issue, I got that it's because of my System.currentPageReference() is returning a null object instead of a pagereference. Is my code is out of the scope? Any idea would be appreciated.
I'm doing this inside my remoteAction method like follows
@RemoteAction Global static void saveRecord(String[] recordValues) { if(recordValues.size()>0) { PageReference recordId = System.currentPageReference();//.getParameters().get('id'); } }
I know there may be lots of other possible ways to do this rather than remoteAction, but this time I need to get the context of the System.currentPageReference() as well.
Thanks,
Madhura
Hi madhu,
Using RemoteAction you can't get the "System.currentPageReference()" in your controller method.
but using javascript you can get the value of your VF page's parameter and Pass that valuein your RemoteAction method.
For more information see below example..
Visualforce Page:
Apex Class:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/
All Answers
Hi madhu,
Using RemoteAction you can't get the "System.currentPageReference()" in your controller method.
but using javascript you can get the value of your VF page's parameter and Pass that valuein your RemoteAction method.
For more information see below example..
Visualforce Page:
Apex Class:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/
Thanks hitesh90 for the quick response.
Your trick is working. But as I have asked in the question also, what I need to know clearly is the context of System.currentPageReference(). I tried to find out this hear and there but could not. Thanks for addressing it and so accepting your answer.
For the id issue what I did as an alternative is just load the assign the id also to a variable since I'm using that objects's standardController. No any extra work needed for that. But I love hitesh90's regex :)
Thanks,
Madhura