I want to pass values from one page another page which have different controllers without using querystring. How can i pass more than 100 values?

  • 2
    Have you considered just using the same controller for both VF pages? It seems like they have a lot in common with that many values. Another option might be to store the values in a custom object or custom setting.
    – Phil B
    Commented Oct 7, 2013 at 12:28
  • Am using different controllers..
    – Reddy
    Commented Oct 7, 2013 at 12:30

2 Answers 2


There are a few ways to accomplish this:

  1. If two pages are using the same controller and extensions (or a subset), you can just return a PageReference to the other page while not setting redirect to true (leave it as the default false). The context will automatically be passed along for you. You can experiment with this to see how it works best for you. We've had great success with this in our projects.

  2. Modern browsers support parameters that are thousands or tens of thousands of characters long, and I'm not aware of any inherent limitation that you'd reach on the platform itself in terms of parameter length. Conceptually, you could just pass this data along the URL, keeping in mind that this exposes the data to the end user (so this can allow replays, it's stored in history, etc). Some proxies don't support long URLs, though, so try to keep it reasonable if you expect some users to be using proxies. We're using this in some legacy code in our projects, and it works well, even with 100+ parameters with an average name length of 10 characters and an average value length of 11 characters (i.e. an average of 23 characters per parameter value, including the separating equals and ampersands).

  3. You can store the data in a custom record somewhere, and retrieve that data. This lets you pass just a single ID value instead of transferring a huge view state. This is much more bandwidth friendly than either of the first two solutions, but will have inherent limits on the amount of data that can be stored per field/record. We don't specifically use this technique, but it is definitely viable.


This can be possible using static variable

In first controller:

class FirstController
   // Call this method and set static variable for next VF page's controller 
   public void setVar()
       SecondController.staticVar = 'someValue';

You will get same value when loading another visualforce page have this controller

    public class SecondController
       public String staticVar;
       public String instanceVar {get; set;}

       public SecondController()
           instanceVar = staticVar;

But note that redirection must be from FirstVFpage to SecondVFpage by commandlink, commandbutton, pagereference etc. so context remain same.

Hope this help.

  • does this really work??i was trying this out..and did not work?I used a commandbutton though
    – sfdc99999
    Commented Nov 23, 2013 at 1:48
  • I have two VF VF1,VF2 page and two controllers C1,C2.C1 have Account id I want use this id into an other VF Page.Before C1 called to VF2 then again called to C2 controller.Please share the code, thanks. Commented Dec 23, 2013 at 11:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .