Multiple Extension problem

I am working on Visualforce page which using standardController and has multiple extension.

<ape:page StandardController = 'CustomObject__c' extension = 'ClassA,ClassB'> 
       {!obj.field__c}
</apex:page> 

    class classA {
       public CustomObject__c Obj{get;set;}
       public ClassA(ApexPages.StandardController stdController) {
            this.obj = (CustomObject__c)stdController.getRecord();
        }
    }

Now there is child window which class B as controller.

   <apex:page  Controller = 'ClassB' > 
        how to access obj here something like 
         {!obj.field__c}
   </apex:page>

   Class classB {
         i have to get obj here , assign some values and
         refersh the parent page with Standard Controller 
         to reflect the information 
     }

if I do below in Class B , It intiate a complete new record…

class classB public ClassB(ApexPages.StandardController stdController) {
            this.obj = (CustomObject__c)stdController.getRecord();
        }

Answer

Because you’re using two pages this isn’t going to work, the controllers live in different execution contexts and so can’t share data.

Instead you’re going to have to load the record using the ID (passed as a page parameter) in controller B, modifiy it, and then use Javascript to refresh the parent page when the child window is closed.

Attribution
Source : Link , Question Author : amidstCloud , Answer Author : Matt Lacey

Leave a Comment