+ Start a Discussion

Pass Controller to Visualforce Page?

I am working on a project that has a requirement which needs to have PDF generation of documents.  I have created the Visualforce page, but the issue that is coming up is that sometimes, hundreds of PDF documents need to be created.  I"ve managed to create the controller in such a way that ALL information necessary for rendering the page can be done in a single SOQL query, but this will not fix the case where I have lots of documents as it violates the SOQL query limit.  Is there some way to instantiate the controller and then have the Visualforce page use that already instantiated controller?


One idea I came up with was to create a List<> of objects that are going to be used for generating the PDF.  Then, for each object, use JSON.serialize() to create a string, put the string into the ApexPage's parameter map, and deserializde the object in the default constructor of the page's controller.  This would mean that the Page itself would never have to do any SOQL queries.  The problem I've seem to run into is that deserialize doesn't seem to work correctly on "child" objects (i.e. the object that is being rendered also has child objects).


Any help would be appreciated.  Thanks in advance.