function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
OdedHarnivOdedHarniv 

Passing/accessing parameters on another controller

Hello

 

I have this case which I can't figure out:

 

I have two pages each with a different custom controller.

I want to access variables on PageA controller from PageB controller.

 

Is there anyway to achieve this?

 

Thanks

 

Oded

 

Best Answer chosen by Admin (Salesforce Developers) 
Guns1974Guns1974

Oded,

 

Your requirement is bit different.  As 2 pages are accessible as 2 seperate tabs, various scenarios are possible.

User go to PageA and then to PageB or viceversa. It's quite possible that user may go to some different tab in between. So anything stored as an variable in controller will not be accessible on other tab. That's why I suggested you to use cookie which will be available thoughout that session.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites_cookie.htm

 

Let me know if you need additional help.

 

Regads

G

All Answers

Guns1974Guns1974

If your control/flow of pages is from PageB to PageA, then you can pass parameters on querystring like :

 

apex/PageA?Param1=abc

 

In your PageA Controller you could access Param1 using currentParameter.

OdedHarnivOdedHarniv

Hi

 

In my case these two pages make up two tabs, so the order is not predefined.

 

I need to be able to access each from the other.

I thought to maybe use and extension controller but I'm not sure it will work and maybe there is a better practice?

 

Any advice?

 

Oded

Guns1974Guns1974

If order is not predefined, then why don't you use cookie to store this data. Whichever page is clicked first will validate if cookie exists and set value accordingly. Same value will be available in other tab/page whenever user clicks on it.

 

OdedHarnivOdedHarniv

I've never used cookies so it didn't occur to me to use it for this case.

I'll go an learn the issue and try it out.

 

Thanks a lot

 

Oded

Guns1974Guns1974

Oded,

 

Your requirement is bit different.  As 2 pages are accessible as 2 seperate tabs, various scenarios are possible.

User go to PageA and then to PageB or viceversa. It's quite possible that user may go to some different tab in between. So anything stored as an variable in controller will not be accessible on other tab. That's why I suggested you to use cookie which will be available thoughout that session.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites_cookie.htm

 

Let me know if you need additional help.

 

Regads

G

This was selected as the best answer