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
sravusravu 

rerender not working properly with actionsupport

Hi,

 

Beased on first radio button selection, i am showing the list of options and based on the option selected I am getting the contacts associated to the records from the controller. When i first select the result is coming as expected, whe I select another option from the list it is not giving the expected list.

 

Here is my visulaforce page code :

 

<apex:page standardController="Bugs__c" tabStyle="Bugs__c" extensions="emailCustomerswhenbugisfixed" action="{!init}">
    <apex:pageMessages ></apex:pageMessages>
    <apex:form >
        <apex:pageBlock title="Email to Customers" > 
           <apex:pageBlockSection columns="2">
               <apex:outputText value="Bug fixed in:"/>         
               <apex:selectRadio value="{!fixOption}">
                   <apex:selectOptions value="{!FixedOptions}"/>
                    <apex:actionSupport action="{!showOptions}" event="onclick"/>
               </apex:selectRadio><br/>
               <apex:outputPanel rendered="{!showSPOptions}">                    
                        <apex:outputText value="SP Fixed"/> &nbsp; &nbsp; &nbsp; &nbsp;
                        <apex:selectList value="{!SpFixed}" size="1">                          
                            <apex:selectOptions value="{!SpOptions}"/>
                            <apex:actionSupport action="{!showSPList}" event="onchange" reRender="out"/>                           
                        </apex:selectList> 
                           </apex:outputPanel>
                             <apex:outputPanel rendered="{!showVersionOptions}">
                  
                        <apex:outputText value="Version Fixed" /> &nbsp; &nbsp; &nbsp; &nbsp;
                      <apex:selectList value="{!VersionFixed}" size="1" >
                             <apex:selectOptions value="{!VersionOptions}"/> 
                       <apex:actionSupport action="{!showVersionList}" event="onchange" reRender="out1"/>                        
                        </apex:selectList>
                                 </apex:outputPanel>
           </apex:pageBlockSection>        
        </apex:pageBlock>  
                 
         <apex:outputPanel id="out">
   <apex:outputpanel style="display:block;width:100%;" rendered="{!showContactsSP}">
              <apex:pageBlock >
                    <apex:pageBlockButtons location="top">
                        <apex:commandButton value="Send Email" action="{!sendEmailSP}"/>
                    </apex:pageBlockButtons>
                    <apex:pageBlockSection title="List of Contacts">     
                          <apex:pageBlockTable value="{!ContactsSP}" var="c" width="100%">
                                <apex:column value="{!c.Name}"/>
                                <apex:column value="{!c.Email}"/>
                                <apex:column value="{!c.Account.Name}"/>
                          </apex:pageBlockTable>                   
                    </apex:pageBlockSection>
             </apex:pageBlock>
  </apex:outputpanel>
      </apex:outputPanel>

      <apex:outputPanel id="out1">
     
        <apex:outputpanel style="display:block;width:100%;" rendered="{!showContactsVersion}">
              <apex:pageBlock >
                    <apex:pageBlockButtons location="top">
                        <apex:commandButton value="Send Email" action="{!sendEmailVersion}"/>
                    </apex:pageBlockButtons>
                    <apex:pageBlockSection title="List of Contacts">     
                          <apex:pageBlockTable value="{!ContactsVersion}" var="c" width="100%">
                                <apex:column value="{!c.Name}"/>
                                <apex:column value="{!c.Email}"/>
                                <apex:column value="{!c.Account.Name}"/>
                          </apex:pageBlockTable>                   
                    </apex:pageBlockSection>
             </apex:pageBlock>
   </apex:outputpanel>
       </apex:outputPanel> 
    </apex:form>
</apex:page>

 Here is my controller:

 

public class emailCustomerswhenbugisfixed{
    
    public String fixOption {get;set;}
    public Boolean showSPOptions {get;set;}
    public Boolean showVersionOptions {get;set;}
    public String VersionFixed {get;set;}
    public String SPFixed {get;set;}
    public List<String> emailListSP = new List<String>();
    public List<String> emailListVersion = new List<String>();
    public List<Contact> conSP{get;set;} 
    public List<Contact> conVersion{get;set;} 
    public boolean showContactsSP {get;set;}
    public boolean showContactsVersion {get;set;}
    
    public emailCustomerswhenbugisfixed(ApexPages.StandardController controller) {
        showSPOptions=false;
        showVersionOptions=false;
        VersionFixed='';
        SPFixed='';
        showContactsSP=false;
        showContactsVersion=false;
    }
    
        public List<SelectOption> getSpOptions(){
        List<SelectOption> option = new List<SelectOption>();
        option.add(new selectoption('Select','Select'));
        option.add(new selectoption('10.0 SP2','10.0 SP2'));
        option.add(new selectoption('10.0 SP1','10.0 SP1'));
        option.add(new selectoption('9.3.1 SP2','9.3.1 SP2'));
        option.add(new selectoption('9.3.1 SP1','9.3.1 SP1'));
        option.add(new selectoption('9.3 SP1','9.3 SP1'));
        option.add(new selectoption('9.2 SP6','9.2 SP6'));
        option.add(new selectoption('9.2 SP5','9.2 SP5'));
        option.add(new selectoption('9.2 SP4','9.2 SP4'));
        return option;    
    }
        
    public List<SelectOption> getVersionOptions(){
        List<SelectOption> option = new List<SelectOption>();
        option.add(new selectoption('Select','Select'));
        option.add(new selectoption('10','10'));
        option.add(new selectoption('9.3.1','9.3.1'));
        option.add(new selectoption('9.3','9.3'));
        option.add(new selectoption('9.2','9.2'));
        option.add(new selectoption('9.1','9.1'));
        option.add(new selectoption('9','9'));
        option.add(new selectoption('8.3','8.3'));
        return option;    
    }
    
    public void showOptions(){
        if(fixOption=='Service Pack'){
            showSPOptions=true;
            showVersionOptions=false;
        }
        if(fixOption=='Version'){
            showVersionOptions=true;
            showSPOptions=false;
        }
    }
    
    public void ShowVersionList(){
        showContactsSP=false;
        showContactsVersion =true;
    }
    
    public void ShowSPList(){
        showContactsSP=true;
        showContactsVersion =false;
    }
    
        
    public List<Contact> getContactsSP(){
        Set<string> proNames = new Set<String>();
                List<BugCase_Association__c> bugs = [Select Id,Bug__c,Case__c,Case__r.ContactId,Bug__r.Name,Bug__r.SP_Fixed__c from bugcase_association__c 

where Bug__r.SP_Fixed__c=:SpFixed];
                for(BugCase_Association__c b : bugs){
                if(proNames.contains(b.Case__r.ContactId)){                                       
                      system.debug('DUP PRESENT');                
                  }                   
                  else {                      
                   proNames.add(b.Case__r.ContactId);                     
                   system.debug('DUP NOT PRESENT');                    
                   emailListSP.add(b.Case__r.ContactId);         
                 } 
               } 
               System.debug(emailListSP);
               conSP = [Select Id,Name,Email,AccountId,Account.Name from COntact where Id IN :emailListSP];
               System.debug(conSp);
               return conSP;
       }
      
     public List<Contact> getContactsVersion(){
              Set<string> proNames1 = new Set<String>();
                List<BugCase_Association__c> bugs = [Select Id,Bug__c,Case__c,Case__r.ContactId,Bug__r.Name,Bug__r.Version_Fixed__c from 
               bugcase_association__c where Bug__r.Version_Fixed__c=:VersionFixed];
                for(BugCase_Association__c b : bugs){
                  if(proNames1.contains(b.Case__r.ContactId)){                                       
                      system.debug('DUP PRESENT');                
                  }                   
                  else {                      
                   proNames1.add(b.Case__r.ContactId);                     
                   system.debug('DUP NOT PRESENT');                     
                   emailListVersion.add(b.Case__r.ContactId); 
                  }                  
                }
                System.debug(emailListVersion);
                conVersion = [Select Id,Name,Email,AccountId,Account.Name from COntact where Id IN :emailListVersion]; 
                System.debug(conVersion);
                return conVersion;
    }
    

    Public List<SelectOption> getFixedOptions(){
        List<SelectOption> option = new List<SelectOption>();
        option.add(new selectoption('Service Pack','Service Pack'));
        option.add(new selectoption('Version','Version'));
        return option;
    }

    public PageReference init(){
        Profile p = [select Id,Name from profile where Id=:userinfo.getProfileId()];
        if(p.Name!='UAG Manager'){
             PageReference pageRef = new PageReference('https://cs3.salesforce.com/a0J?fcf=00BQ0000000vfiK');
             pageRef.setRedirect(true);
             return pageRef;
        }
        return null;
    }
    
      public PageReference sendEmailSP(){
        try{           
            if(!emailListSP.isEmpty()){
                Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
                mail.setTemplateId('00XQ0000000IFYF');
                mail.setSenderDisplayName('Esri Support');
                mail.setTargetObjectIds(emailListSP);
                //mail.setWhatIds(spBugs);
                Messaging.sendEmail(new Messaging.Massemailmessage[] {mail});
                PageReference pageRef = new PageReference('https://cs3.salesforce.com/a0J?fcf=00BQ0000000vfiK');
                pageRef.setRedirect(true);
                return pageRef;
            }
            else{
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Could not find the bugs listed in this fix'));
                return null;
            }
        }
        catch(Exception e){
           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
           return null;
        }
    }
    
    public PageReference sendEmailVersion(){
        try{           
            if(!emailListVersion.isEmpty()){
                Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
                mail.setTemplateId('00XQ0000000IFcH');
                mail.setSenderDisplayName('Esri Support');
                mail.setTargetObjectIds(emailListVersion);
                //mail.setWhatIds(versionBugs);
                Messaging.sendEmail(new Messaging.Massemailmessage[] {mail});
                PageReference pageRef = new PageReference('https://cs3.salesforce.com/a0J?fcf=00BQ0000000vfiK');
                pageRef.setRedirect(true);
                return pageRef;
            }
            else{
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Could not find the bugs listed in this fix'));
                return null;
            }
        }
        catch(Exception e){
           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
           return null;
        }
    }
}

 Could anyone help me with this

 

Thanks in advance.