[SalesForce] Can 2 Vf pages use the same controller and share the data

Here is a scenario where i have a search page with filters for users to select and display the search results. I also have a button to generate the pdf.

I have a list of account in the controller which displays the search result. I am doing the exact same thing in the page i am generating the pdf except that i am passing the selected parameters into vf page rendered as pdf and requerying it and generating the list.

These work fine.. But now i need to give an ability to remove some search result records and this needs to be generated as pdf.

I was wondering if i can share the data from the search page to VF page if i was using the same controller?

Best Answer

Yes, the view state will be shared across Pages, which share a controller, so long as you don't perform a redirect, because this flushes the view state.

If set to true, a redirect is performed through a client side redirect. This type of redirect performs an HTTP GET request, and flushes the view state, which uses POST. If set to false, the redirect is a server-side forward that preserves the view state if and only if the target page uses the same controller and contains the proper subset of extensions used by the source page.

Related Topic