I have one Apex Class. I want to access that Apex Class variable from other controller classes. If I'll change the value from any controller, then that same value should be available to all controller.
This is my Main CLass .....
Class public virtual class GenericControllerClass1 {
public static integer A{get;set;}
public GenericControllerClass1(){
System.debug('$$$$$$$$$$$$$$ Main Class%%%%%%%%%%%%%'+ A);
}
}
My First Controller is ......
public class TestControllerClass1 extends GenericControllerClass1{
public TestControllerClass1(){
GenericControllerClass1.A = 998;
System.debug('###############'+ GenericControllerClass1.A);
}
public Pagereference CallMe(){
Return page.P2;
}
}
My Second Controller is .........
public class TestControllerClass2 extends GenericControllerClass1{
public TestControllerClass2(){
System.debug('================='+GenericControllerClass1.A);
}
}
My First Page P1......
<apex:page controller="TestControllerClass1" >
<Apex:form >
<apex:pageBlock title="Testing For Virtual Class">
<apex:pageBlockSection title="Input Value in Virtual Class">
<apex:commandButton value="Redirect" action="{!CallMe}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</Apex:form>
</apex:page>
My Second page P2......
<apex:page controller="TestControllerClass2">
<apex:pageBlock title="Testing For Virtual Class">
<apex:pageBlockSection title="Output Value in Virtual Class">
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
My both Vf pages refering to the different Controller like ... Controller1 & Controller2.Both the controller also refer to the same Main-Class. I'm using DebugLog to check the value of 'A' of second controller. But the value itself is showing 'null' there . I want to access the value of 'A' at Controller2, that(998) I have inserted in my controller1... Where both the controller extends the Main controller variable. But in all cases value of 'A' in 'Main Class' & Second-Controller are showing null.. So how to get this value in any controller.. ???