Activity › Forums › Salesforce® Discussions › How can I take parameters from one page to another with different controllers in Salesforce?
Tagged: Controller Class, Controller type, Custom Controller, Parameter, Salesforce Apex, Salesforce Controller, Salesforce SOQL
-
How can I take parameters from one page to another with different controllers in Salesforce?
Posted by Rachit on April 14, 2016 at 9:12 AMHow can I take “n” number of parameters from one page to another with different controllers ??
shariq replied 7 years, 7 months ago 5 Members · 4 Replies -
4 Replies
-
Hi Rachit,
Try this link:-http://www.forcetree.com/2009/06/passing-parameters-to-visualforce-page.html
Hope this helps you.
- [adinserter block='9']
-
Hi,
You can use the below code snippet for this
public Pagereference gotonewpage()
{
PageReference pageRef = Page.existingPageName;
pageRef.getParameters().put(‘msg’,’success’);
return PageRef
}This will make your URL looks like this //na5.salesforce.com/apex/SamplePage2?msg=success
Retrieve Parameter Values in Apex Class:
public class Sampleclass
{
Public String message = System.currentPagereference().getParameters().get(‘msg’);
}Hope this helps you.
-
Hi,
Step 1: Create a Visualforce page called SamplePage1
<apex:page >
<apex:outputlink value=”/apex/SamplePage2″> Click Here <apex:param name=”msg” value=”success”/> </apex:outputlink>
</apex:page>Step 2: Create a Visualforce page called SamplePage2
<apex:page controller=”Sampleclass”> </apex:page>
Step 3: On SamplePage1 Click on the ” Click Here” link. You will see that when you click on the link you will navigate to the SamplePage2. Check the URL now..
https://na5.salesforce.com/apex/SamplePage2?msg=success
You can see that the parameter ” msg” with value “success” has been passed to the new page.
Retrieve Parameter Values in Apex Class:
public class Sampleclass
{
Public String message = System.currentPagereference().getParameters().get(‘msg’);
}Thanks
-
Hi,
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.Hope this helps.
Log In to reply.