2

I am trying to pass url parameters between Apexpages and component but am not successful in achieving this. When I call ApexPages.currentPage.getParameters().put('test','aaa')

in a pagecontroller and then call ApexPage.currentPage.getParameters().get('test') in a component controller which resides in that page. The method returns nothing. Can someone tell me how can I persist the url parameters between page controller and component controller?

thank you

  • maybe my question was not clear. I have a page with pagecontroller and in this page there is a component with component controller. what I am trying to do is call Apexpages.currentpage().getparameters().put in pagecontroller and call Apexpages.currentpage().getparameters().get in componentcontroller. I tried this and get nothing returned. should this not share the same link url and parameters ? – Shuo Wang Jun 12 '16 at 6:51
2

I think your question was unclear. You said that the value needs to be pass from the page to controller.but if the value is dynamic then you have to workaround on <apex:param> tag.

If you are passing the parameters like ID then You have to append the URL of vf page with your ID and value like below

https://yourdomainname/apex/vfpagename?test=value

And get the parameter in the controller using

ApexPages.currentPage.getParameters().get('test');

Update:

Try the below link

https://developer.salesforce.com/forums/?id=906F000000096wsIAA

Hope this might helps....

  • thanks for your comment, I am not passing parameter from page to page controller, I am trying to read page paramters in a component controller. the component is in that page and I think It share the same link with the page. – Shuo Wang Jun 12 '16 at 6:46
  • Try like in my updated link – Subhash Jun 12 '16 at 7:33
  • thank for the link, unfortunately I can't add new attribute to our existing component, there is a button on component it just redirect to the current page and refresh the current page, then all my page parameters is gone. what I can change is the return behavior, I have solved this by add cookie, put all my parameters in cookie and then if the component cancell button is clicked, then I set another cookie. which the page loading again, i have the url parameter cookie and the cookie set by cancel button, then I can read the parameters again and delete the cookie set by compoent cancel button. – Shuo Wang Jun 13 '16 at 19:32
0

You can use like this:

PageReference pageRef = ApexPages.currentPage();

pageRef.getParameters().put('test', ApexPages.currentPage().getParameters().get('test'));

pageRef.setRedirect(true);

return pageRef;
  • yes, I did this, I have a page and in that page there is an component. what I am trying to do is, call apexpages.currentpage().getparameters().put() in the page controller, and want to get this url parameter in component controller. – Shuo Wang Jun 12 '16 at 6:48
  • Would you mind to put your code please. – Santanu Boral Jun 12 '16 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.