I have a VF page with two controller extensions…i.e. extensions="Ext1,Ext2"
In my Ext2 class I have some search functionality implemented that allows the user to select records that can be added to another list of records that are already stored in Salesforce that are displayed on the page.
I'm storing the records searched into a static list public static List<Product2> productsToAdd;
that is contained in the Ext2 controller class.
Is it possible to pass that value to the Ext1 controller class?
I was trying to access it in the Ext1 class from a method calling the static variable, but it comes back null.
public void addSelectedProducts() {
system.debug('******************************* Ext2.productsToAdd ' + Ext2.productsToAdd);
system.debug('******************************* Ext2.testStaticString ' + Ext2.testStaticString);
}
I thought by having both controllers chained in the extensions attribute that I might be able to pass values from one controller to another. Is there a way to accomplish that?
Best Answer
One solution is listed in this blog post of mine Referencing one controller extension from another controller extension.
The technique is to use a registry class that is held in the view state:
that the controller extensions can lookup each other through: