+ Start a Discussion
Amit ChaudharyAmit Chaudhary 

How can i pass list<object__c> one vf page to another . ?

bob_buzzardbob_buzzard
It depends on the controllers that the pages use.  If they both use the same controller, you can simply store the list in a controller property and it will be available in the second page.  If they use different controllers, you'll need to pass the information as parameters on the URL.  I typically just pass the ids and leave it up to the target page controller to retrieve the full sobject record - so the URL looks like:

/apex/MyTargetPage?id1=<id of first sobject>&id2=<id of second sobject>...




RishavRishav
HIi Amit,

         Better solution is to use same controller for both pages. Because passing the large data through query string is never a good idea.
Rishav
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
@bob_buzzard:Can you give some sample code snippet  passing a list of records from one VF page to Another VF page through URL
 Example:
Name:bob,desc:....,number:.....;
Name:Sagar.desc:.......,number.........;
all these list of records can be passed thriugh URL
bob_buzzardbob_buzzard
@Rishav - care to suppy a citation for this?  Query strings can cope with large amounts of data these days and there's not a lot of difference between a GET request and the POST that would be required when sharing controllers.
bob_buzzardbob_buzzard
As I stated in my answer, its better just to pass the ids of the records and then retrieve these in the target page controller than to try to serialize an sobject via URL parameters - you are likely to hit formatting issues if there are special characters in any of the fields for example.

To add the list of ids from a controller method, it would be something like the following (assuming that you have the sobjects in mysobjlist) :

public PageReference GotoTarget()
{
    PageReference pr=Page.TargetPage;

    Integer idx=1;
    for (Sobject sobj : mySobjectList)
    {
       pr.getParameters().put('id' + idx, sobj.get('id');
    }

    return pr;
}



Dane HortonDane Horton
Hi Bob,
     I'm a newbie , and was searching for a solution to my current challenge. Can you  give an example of how you would "store the list in a controller property"  I am kinda facing a similar challenge where I am executing a SOQL search from one VF page  but would like to DISPLAY the results on a totally separate\new page .  I can successfully execute the SOQL search and display the results on the same page .  But would like to display on a NEW page