You need to sign in to do that
Don't have an account?
SFDC coder
Pass Values from one page to another without using query string params
Hi,
I would like to know if there is any way to pass values to another VF page other than passing it from Query String parameters?
If we want to pass a list of records then passing each field through query string parameters won't be a right way
Thanks,
Neha Patil
I would like to know if there is any way to pass values to another VF page other than passing it from Query String parameters?
If we want to pass a list of records then passing each field through query string parameters won't be a right way
Thanks,
Neha Patil
this is a small example how to pass the accountids as parameters and in the next page you just need to split(',') and then do the select.
public with sharing class VFC01_Account
{
public list<Account> listAcc= new list<Account>();
public VFC01_Account ()
{
listAcc=[select id,name
from Account
limit 10];
}
public PageReference DoRedirect()
{
PageReference retVal= Page.Page2VF;
string AccountIds='';
foreach( Account acc :listAcc)
{
AccountIds +=acc.Id+',';
}
retVal.getParameters().put('AccountIds', AccountIds);
retVal.setRedirect(true);
return retVal;
}
}
All Answers
You can use the same class controller and the list of record will keep the records while passing from a page to another.
check this link it will give you a clear vision
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_quick_start_wizard.htm
Good Luck
Apart from this is there any ohter way to share the data of one page to another page?
Regards,
Neha Patil
In case you can't use the same controller , the solution is to pass the Ids of the list in one parameter using query string and in the other VF page you need to do select on these ids to have the list again.
Regards
If it is happening in a single execution order you can try to use static variables
Ta
Vish
this is a small example how to pass the accountids as parameters and in the next page you just need to split(',') and then do the select.
public with sharing class VFC01_Account
{
public list<Account> listAcc= new list<Account>();
public VFC01_Account ()
{
listAcc=[select id,name
from Account
limit 10];
}
public PageReference DoRedirect()
{
PageReference retVal= Page.Page2VF;
string AccountIds='';
foreach( Account acc :listAcc)
{
AccountIds +=acc.Id+',';
}
retVal.getParameters().put('AccountIds', AccountIds);
retVal.setRedirect(true);
return retVal;
}
}