function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Srikanta BiswalSrikanta Biswal 

How to pass text from one VF page to another VF witout query string?

Best Answer chosen by Srikanta Biswal
VahidVahid
I think as per your requirement you don't want to show value on the address bar, so there may be 2 ways:
1. Both VF Page have same controller:
If both pages have same controller then we don't need to pass parameters and can access variables. 

2. Create Form on Page with method="Post" and use your value to in the input:hidden and as per you requirement and submit form. 

Thanks
Abdul Vahid

All Answers

KaranrajKaranraj
Using PageReference in the apex controller class you can able to pass value from one VF page to another as a parameter

First visualforce page controller class
String value = 'Pass value in this variable";
String url = '/apex/VFPageName2?param1=' + value; 
PageReference pageRef = new PageReference(url);
pageRef.setRedirect(true);
return pageRef;

Second visualforce page controller class
String param_value = system.CurrentPageReference.GetParameters().get('param1');

 
VahidVahid
I think as per your requirement you don't want to show value on the address bar, so there may be 2 ways:
1. Both VF Page have same controller:
If both pages have same controller then we don't need to pass parameters and can access variables. 

2. Create Form on Page with method="Post" and use your value to in the input:hidden and as per you requirement and submit form. 

Thanks
Abdul Vahid
This was selected as the best answer
Ramon PereiraRamon Pereira
Try this: 
Public class YourController {

//Constructor 
public YourController(){
//Get parameter 
 String idAcc = Apexpages.currentPage().getParameters().get('idAcc');
}

public Pagereference yourRedirect(){
String mySOQL = 'SELECT ID FROM Opportunity limit 2  ';
  Pagereference yourVisualPage = new Pagereference( '/apex/YourPAGE' );
   // put parameter
     yourVisualPage.getParameters().put( 'soql', mySOQL );
      return yourVisualPage.setRedirect( true );
}

}

Instead of spending the SOQL via URL, pass a parameter to another page that your controller to perform the query.

I hope this helps.