1

I have a very simple question for those who aren't as novice in visualforce as I am.

Currently I have a visualforce page that has an id associated to it by using the JavaScript code:

'/apex/ExampleLabel' + '?id=' + '{!ECS__RMA__c.Id}'

In the controller class I am getting the Id by:

Id xId = ApexPages.currentPage().getParameters().get('id');

Which works. My very simple question is this: What is the visualforce counterpart to the above apex code? Essentially I want the visualforce code to read the page's Id. Is there a simple command to do this?

Also for future reference how do I encode more variables onto the url for a visualforce page? I know that doing the above JavaScript code will put the ID on the page, but what if I wanted to put, say, the value of {!Example} and call it from another visualforce page?

3

You can use {!$CurrentPage.parameters.id} to read the parameter (or any parameter, really) from the page. Remember to put that in quotes if you're going to use that within javascript.

Regarding new parameters:

If you use Apex you can do ApexPages.currentPage().getParameters().put(<paramName>, <paramValue>);.

If you are going to redirect using Javascript, use simple querystring syntax: http://<theurl>?Param1=Value1&Param2=Value2...

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.