Hello friends, In this tutorial, You are going to see How to Pass Parameter from Visualforce Page to another. This is a very common situation for any web application to Pass data from one Page to another Page.

How to Pass Parameter from One Visualforce Page to another

Create a Visualforce Page called FistPage.vfp from where you will pass the value to the second Visualforce Page

FirstPage.vfp

<apex:page controller="FirstPageController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >Enter the text to be passed: <apex:inputText value="{!sValue}"/></apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Go to Next Page" action="{!CallNextPage}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Create an Apex class called FirstPageController.

FirstPageController

public class FirstPageController {
public String sValue{get;set;} 
public FirstPageController()
{
 
}
public PageReference CallNextPage()
{
PageReference pg=new PageReference('/apex/SecondPage');
pg.getParameters().put('p1',sValue);
pg.setRedirect(false);
return pg;
}
}

Create a second Visualforce Page which will receive the parameter passed from fist Visualforce Page.

SecondPage.vfp:

<apex:page controller="SecondPageController" >
The received value is {!sValue}
</apex:page>

Create an apex class called SecondPageController.

SecondPageController

public class SecondPageController {
public String sValue{get;set;}
public SecondPageController()
{
sValue=ApexPages.currentPage().getParameters().get('p1');
 
}
}

Output:

Pass Parameter

Click on the Go to Next Page.

Pass Parameter

View More:

Conclusion:

I hope this is a useful topic for you. Please comment for any technical help. Your feedback and suggestions would be appreciated.

Thank You.

6 Comments

  • Thanks for a marvelous posting! I truly enjoyed reading it, you may be a great author.I will make certain to bookmark your blog and will come back in the future. I want to encourage you continue your great posts, have a nice morning!|

  • I do believe all of the concepts you’ve introduced for your post. They’re very convincing and can definitely work. Nonetheless, the posts are too quick for beginners. May you please lengthen them a little from next time? Thank you for the post.|

  • Hi there to every one, the contents present at this website are genuinely awesome for people knowledge, well, keep up the good work fellows.|

  • It’s hard to find experienced people about this subject, but you seem like you know what you’re talking about! Thanks|

  • We’re a group of volunteers and opening a new scheme in our community. Your web site provided us with valuable information to work on. You’ve done a formidable job and our whole community will be thankful to you.|