0

I has created global Controller class "OneInstanceController" for visualforce page "OneInstance". In my case I open a lot of pages "OneInstance" in multiple tabs. Each page should be copy of others for all time. I need use only one instance of controller class for each created page. Can I do it?

my problem: Page use in custom component in sidebar. And when I open new tab (Sales app), new page is created, new Instance of controler is created and I miss all variables in controller - they are also reloaded.

Use one instance of controller, it help me, I think.

2
  • 1
    What is the page trying to accomplish? If you share your controller code it will be much easier for us to help you.
    – Adrian Larson
    Oct 13, 2015 at 22:03
  • They're trying cross-page communication, a "singleton" type design, to avoid some problem they're having with pages doing Something Bad when more than one tab is open.
    – sfdcfox
    Oct 13, 2015 at 22:05

1 Answer 1

2

Web browsers don't naturally allow a single page to exist in multiple windows at once, so you really can't have "just one controller" across the entire session. There will necessarily be one controller and page per tab open. However, what you can do is use sessionStorage to maintain state across all pages, or you could leverage a WebWorker to share data (warning: IE doesn't support sharing workers). However, this means that you're going to need to make most of your logic client-side instead of server-side. The client will need to event-driven to accept events that could occur from other pages. Without specific details of what you're trying to do, I'm afraid I can't give you too much more information. However, to feel free to ask here or over on StackExchange.

You must log in to answer this question.

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