+ Start a Discussion
BrabasBrabas 

How I can call variables, between 2 controller extensions?

I have a page that generates a receipt number depending on the type of payment selected.

 

<apex:page  standardcontroller="Policy__c" extensions="policyControllerIntA,RecordPolicy"  ">

<apex:form id="Policy">

        <apex:pageBlock >       
<apex:pageBlockSection>
  
  <div class="wrap3_1"> 
 <div class="wrap3">  
        <apex:pageblockSection columns="3">
            <apex:actionRegion >
                <apex:dynamicComponent componentValue="{!Section_3}"/>    
            </apex:actionRegion>  
                <apex:dynamicComponent componentValue="{!AddFile}"/>        
        </apex:pageblockSection>       
    </div>   

<apex:define name="wrap">
     <div class="wrap5">  
      <apex:actionRegion >  
        <apex:pageblockSection title="Recibos" id="paystubs" >
            <apex:dynamicComponent componentValue="{!Section_5}"/>
        </apex:pageblockSection>  
     </apex:actionRegion>          
    </div>        
 </apex:define>

</apex:pageBlockSection> 
        </apex:pageBlock>
</apex:form> 
 
</apex:page>

 extensions:

 

public with sharing class policyControllerIntA {
    public policyControllerIntA (ApexPages.StandardController con) { }

public Component.Apex.pageBlockSection  getSection_3(){


        Component.Apex.pageBlockSection s_three=new Component.Apex.pageBlockSection ();
        s_three.id='secthree';     
        s_three.collapsible=false;
        s_three.columns=4;

Component.Apex.SelectList fPayments= new Component.Apex.SelectList( multiselect = false, size = 1 );                  
       fPayments.expressions.value='{!fPayment}';
       fPayments.id='fPayments';
       fPayments.title='Forma de pago';
      
       
      Component.Apex.SelectOption so_Type_Payment= new Component.Apex.SelectOption();
      so_Type_Payment.itemLabel = 'Forma de Pago';
      so_Type_Payment.itemValue  = 'Forma de pago';
      
      
      Component.Apex.SelectOption so_Type_Payment1= new Component.Apex.SelectOption();
      so_Type_Payment1.itemLabel = 'Anual';
      so_Type_Payment1.itemValue  = 'Anual';      

      
      Component.Apex.SelectOption so_Type_Payment2= new Component.Apex.SelectOption();
      so_Type_Payment2.itemLabel = 'Semestral';
      so_Type_Payment2.itemValue = 'Semestral'; 
      
      Component.Apex.SelectOption so_Type_Payment3= new Component.Apex.SelectOption();
      so_Type_Payment3.itemLabel = 'Trimestral';
      so_Type_Payment3.itemValue = 'Trimestral';  
      
      Component.Apex.SelectOption so_Type_Payment4= new Component.Apex.SelectOption();
      so_Type_Payment4.itemLabel = 'Mensual';
      so_Type_Payment4.itemValue = 'Mensual';      
      
      
      Component.apex.actionSupport redPaystubs=new Component.apex.actionSupport();
      redPaystubs.event='onchange';
      Set<String> s1 = new Set<String>{'paystubs','fPayments'};
      redPaystubs.rerender=s1;
       
     
       
     if (fPayment=='Anual'||fPayment=='Semestral'||fPayment=='Trimestral'||fPaymentList=='Mensual'){       
       fPayments.childcomponents.add(so_Type_Payment1);       
       fPayments.childcomponents.add(so_Type_Payment2);       
       fPayments.childcomponents.add(so_Type_Payment3);
       fPayments.childcomponents.add(so_Type_Payment4);  
       fPayments.childcomponents.add(redPaystubs);  
    }else{
       fPayments.childcomponents.add(so_Type_Payment);
       fPayments.childcomponents.add(so_Type_Payment1);       
       fPayments.childcomponents.add(so_Type_Payment2);       
       fPayments.childcomponents.add(so_Type_Payment3);
       fPayments.childcomponents.add(so_Type_Payment4);  
       fPayments.childcomponents.add(redPaystubs);
    }

    s_three.childcomponents.add(niCompany);
    s_three.childcomponents.add(PDescription);
    s_three.childcomponents.add(fPayments);
  


return  s_three;

  }


public Component.Apex.pageBlockSection  getSection_5(){
integer asingNums;
integer Months;
        Component.Apex.pageBlockSection s_five=new Component.Apex.pageBlockSection ();
        s_five.id='sectfive';     
        s_five.collapsible=false;
        s_five.columns=12;
        
  
 
if (fPayment=='Anual'){Months=1;}
if (fPayment=='Semestral'){Months=2;}
if (fPayment=='Trimestral'){Months=4;}
if (fPayment=='Mensual'){Months=12;}

for(integer cont=0; cont<Months;cont++){
  Component.Apex.outputLabel nPaystub=new Component.Apex.outputLabel();
 
if(Months==1 || Months==2){
  nPaystub.value=cont + 1;
              if(cont==0){nPaystub.value=1;asingNums=1;}
                if(Months==2){ 
                              if(cont==0){nPaystub.value=1;asingNums=1;}
                              if(cont==1){nPaystub.value=2;asingNums=2;}
                                }

  }
else{
   if(Months==4 ){ 
              if(cont==0){nPaystub.value=1;asingNums=1;}
              if(cont==3){nPaystub.value=4;asingNums=4;}
              if(cont==1){nPaystub.value=3;asingNums=3;}
              if(cont==2){nPaystub.value=2;asingNums=2;}
            }
                else
                {
                   if(Months==12){
                                 if(cont==0){nPaystub.value=1;asingNums=1;}
                                 if(cont==11){nPaystub.value=12;asingNums=12;}
                                 if(cont==1){nPaystub.value=7;asingNums=7;}
                                 if(cont==2){nPaystub.value=2;asingNums=2;}
                                 if(cont==3){nPaystub.value=8;asingNums=8;}
                                 if(cont==4){nPaystub.value=3;asingNums=3;}
                                 if(cont==5){nPaystub.value=9;asingNums=9;}
                                 if(cont==6){nPaystub.value=4;asingNums=4;}
                                 if(cont==7){nPaystub.value=10;asingNums=10;}
                                 if(cont==8){nPaystub.value=5;asingNums=5;}
                                 if(cont==9){nPaystub.value=11;asingNums=11;}
                                 if(cont==10){nPaystub.value=6;asingNums=6;}
                               }                
                   } 
  }

 /*Component.Apex.inputTextarea....
 Component.Apex.inputTextarea....
 Component.Apex.inputTextarea....*/

return  s_five;

  } 

 and 

public with sharing class RecordPolicy{
    public RecordPolicy(ApexPages.StandardController con) { }

/************************* policy****************************/
 /*Public  String namecustomer{get; set;}
.
.
.*/
 Public  String fPayment{get; set;}
/*.
.  
 Public  Decimal pcommission{get; set;} */ 


 public integer  getnumPay(String fPayment){
  if (fPayment=='Forma de Pago'){return numberPay=1;}//----->
  if (fPayment=='Anual'||fPayment=='ANUAL'){return numberPay=1;}
  if (fPayment=='Semestral'||fPayment=='SEMESTRAL'){return numberPay=2;}
  if (fPayment=='Trimestral'||fPayment=='TRIMESTRAL'){return numberPay=4;}
  if (fPayment=='Mensual'||fPayment=='MENSUAL'){return numberPay=12;}
  return numberPay;
 }


Public PageReference save(){ 
/*
Policy__c p =new Policy__c (
*
*
fPayment__c=fPayment,
*
);

insert p;
parserId(p)
 
*
*/
createPaystub();
//
//
}


public void createPaystub() {
//
//

numPay=getnumPay(fPayment)
//
//

}

fPayment is a figure that interests me Policy__c saved, but it is still necessary for the rerender attribute on another extension. I need to access the contents of fPayment from policyControllerIntA.

Thanks

 

cwall_sfdccwall_sfdc

Could you use an apex:selectList event to set an apex:hidden value that maps to policyControllerIntA variable?