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
bharath kumar 52bharath kumar 52 

actionsupport rerender performance issues

Hi All,

I am working on a requirement where i am supposed to select 1 record. Everything was working but i have performance issues.
public class RadioButtonTest {
public List<contact> selectcon{get;set;}
public integer listSize{get;set;}
public  List<contact> allcons{get;set;}
public Contact con{get;set;}
Public List<contact> getAllContacts()
{
     allcons = [Select Id,FirstName,LastName,Email,Phone from Contact limit 5];
    return allcons;
}    
Public void selectcon()
{
    String selcontactid = System.currentPagereference().getParameters().get('conid');
    con = [Select Id,FirstName,LastName,Email,Phone from Contact where Id=:selcontactid];
    selectcon =  new List<contact>();
    selectcon.add(con);
}

Public List<contact> getselectedContact()
{
if (selectcon!=null)
listSize=selectcon.size();

    return selectcon;
}
public void weeee(){
listSize=selectcon.size();

 try{
if(con.id==null || listSize==0){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Input.');
            ApexPages.addMessage(myMsg);
}
else{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Selected a contact');
            ApexPages.addMessage(myMsg);
system.debug(' Inside weeeeee'+selectcon);
}
}
catch(Exception e){ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Input.');
            ApexPages.addMessage(myMsg);}
}

}


<apex:page controller="RadioButton" showheader="false">
<apex:form >
<apex:pageblock id="allcons" title="Available Contacts">
               <apex:pageblocktable id="allcons" value="{!AllContacts}" var="allcon">
                    <apex:column headervalue="Set as Primary">                    
                       <apex:actionsupport action="{!selectcon}" event="onclick" rerender="consel">  
                        <input type="radio" name="<strong>selectRadio</strong>"  />                    
                            <apex:param name="conid" value="{!allcon.Id}">
                        </apex:param></apex:actionsupport>                            
                    </apex:column>    
                    <apex:column headervalue="Last Name">
                        <apex:outputfield value="{!allcon.LastName}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="First Name">
                        <apex:outputfield value="{!allcon.FirstName}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Email">
                        <apex:outputfield value="{!allcon.Email}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Phone">
                        <apex:outputfield value="{!allcon.Phone}">
                    </apex:outputfield></apex:column>  
                </apex:pageblocktable>
</apex:pageblock> 
<apex:pageblock id="consel" title="Selected Contact">
            <apex:pageblocktable id="allcons" value="{!selectedContact}" var="selcon" >                       
                    <apex:column headervalue="Last Name">
                        <apex:outputfield value="{!selcon.LastName}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="First Name">
                        <apex:outputfield value="{!selcon.FirstName}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Email">
                        <apex:outputfield value="{!selcon.Email}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Phone">
                        <apex:outputfield value="{!selcon.Phone}">
                    </apex:outputfield></apex:column>  
                </apex:pageblocktable>
</apex:pageblock>               
</apex:form>
</apex:page>


User-added image
When i select a contact the below section i.e selected contact gets rerendered. It is only then that i get the "selected contact's id" which will be used for further processing. But there's a lag of 1.8 seconds roughly (before which the selected contact id will be null) 
Any suggestions on improving the performance is greatly appreciated.


Thanks,

Bharath