There was a situation when we were required to pass some values from one visualforce page to another. For achieving this we invoked the second VF page by calling the controller extension of this page using following code.
In the code segment below we are passing two parameters along the page url – ownerid and eventid :
PageReference newPage = new PageReference('/apex/cys_meeting_rooms?ownerid='+event.OwnerId+'&eventid='+event.Id); return newPage.setRedirect(true);
Now here is how to get these values on second VF page :
In salesforce we can get parameter values from the current page url by using global variable $CurrentPage. We can use CurrentPage.parameters.parameterName to reference page request parameters and values, where parameterName is the request parameter being referenced.
For the page url invoked above, we can display the value of eventid parameter in the page url on our VF page as :
<apex:outputText value="{!$CurrentPage.parameters.eventid}">
It will display the values of the page parameter eventId as output text on the VF page.