How to fetch page paramters directly in Visualforce Page?

3:26 PM

A previous post describes how to pass paramters to a Visualforce page, and fetch the passed parameter values in your Apex Class(controller). Click here to read the post.

In this article we will see how to fetch the paramter value directly in your Visualforce page instead of getting it from the Apex Class(controller).

{!$CurrentPage.parameters.paramtername}

This global variable provides the capability.

Let's see a small visualforce example to see how it works.

<apex:page>
  The value of the paramter name passed to this page is :{!$CurrentPage.parameters.name} 
</apex:page>

Save the above Visualforce page with the name  "testpage".

Now, go to the URL bar and type the following address

http://yourinstance.salesforce.com/apex/testpage?name=Edwin

Your Visualforce page will display the output "
The value of the paramter name passed to this page is : Edwin

You can use the apex:param component when you want to pass paramters dynamically between visualforce pages, and the above method works as usual.

0 comments

AD