+ Start a Discussion
VRKVRK 

how to pass values from one VF page to another VF page

Hi all,
Scenaio : How to pass values from one VF page to another VF page.
I have 2 VF pages.   emp VF page and DetailVFpage
i have values firstname, lastname,email, phone in empVFPage and need to pass values to DetailVFpage.

 PageReference pageRef= new PageReference('/apex/DetailVFpage');

i can able to naviage to 2nd VF page(DetailVFPage) after click on link in empVFPage....But values are not passing
1stVFpage
when click on Verification page link, i can able to see Detail VF page..But the values not passing ..
see screenshot the Result page not showing values of VF page firstname, lastname....
2ndVFPage
Anyone have idea on htis
 
Virendra ChouhanVirendra Chouhan
Hi Sekhar,

There are multiple ways to pass value from one page to another. 
  • User same controller in both the VF page so that data is accessible on both.
  • Pass values in URL parameter.
Below link will help you on URL parameter passing:
https://salesforce.stackexchange.com/questions/87704/passing-visualforce-value-to-another-visualforce
arpit vijayvergiyaarpit vijayvergiya
Hello Sekhar,
You can use this to put all values in a pageReference object.
pageReference.put(key',value);

and on the detail page, you can get them in constructor As
ApexPages.currentPage().getParameters().get('key');

You can put multiple parameters with a unique key and get them.

Also, you can use the same controller with getter and setter method.

Thanks,
Arpit vijayvergiya

 
arpit vijayvergiyaarpit vijayvergiya
Hello, following link will help you. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_wizard.htm https://ibirdstechshare.blogspot.in/2018/02/platform-cache-in-salesforce.html Thanks, Arpit vijayvergiya Salesforce Developer
VRKVRK
HI Arpit, 
thanks for your quick replay.. but its not suitable for my requirement
Scenaio : How to pass values from one VF page to another VF page.
i have 2 VF pages  searchPage and Detail Page.
in search Page i can able to display results...But in Detail page i am unable to popullate same values....can you please help on this.
SearchPage  code :
------------------------------------
<apex:pageBlockTable value="{!results}" var="c" rendered="{!NOT(ISNULL(results))}"> 
<apex:column value="{!c.FirstName}" id="fname"/>  
 <apex:column value="{!c.LastName}" />  
 </apex:pageBlockTable>.

Detail Page Code :
--------------------------------
<table>
 <tr>
        <th><font size="2" >First Name</font></th><td><span style="margin-left:150px"> </span></td>
        <th><apex:outputText value=" {!FirstName} "/></th><td><span style="margin-left:150px"> </span></td>
</table>
Controller same for both VF pages:
-----------------------------------------------------
public String FirstName{get;set;}
public PageReference search() {
results= (List<Contact>)[FIND :searchText RETURNING Contact(id,name,email,FirstName,LastNamePhone,Birthdate)][0]; 
}

I can able to display firstname, last name in SearchPage , but i am unable to display same value for  first name and last name in Detail page....

could you please check on this