+ Start a Discussion
RudiHulsbosRudiHulsbos 

Maximum view state size limit (128K) exceeded

Hi All,

 

We developed a visualforce page to display contact records, the visualforce page contains colors based on rankings. The controller return a list of contacts, this list is transient, and the number of contacts returned equals 737 records, but we hit the view state limit error.

 

Please see the controller and VF page code attached. The code is reduced, i left the parts that indicates the intense colour if statements. The VF page displays alot of fields, so could not inclued the full code posting.

 

Any help please???

public class dataTableContacts {

//Public String selectedproject;
//Public List <Invite_Tracking__c> projectlist;
//Public String Projectdropdown = 'No Project Selected';
Public transient List <Invite_Tracking__c> c;



/* public List<SelectOption> getItems() { 
     projectlist = [Select Id, Project__c FROM Invite_Tracking__c ];
      List<SelectOption> options = new List<SelectOption>();      
         options.add(new SelectOption ('0', '-None-'));
   
     for(Invite_tracking__c sa : projectlist){ 
        options.add(new SelectOption(sa.Project__c,sa.Project__c));
    }
       return options; 
    }
    
     
   public String getSelectedProject() { 
    return selectedproject;
       }   
      
   public void setSelectedProject(String selectedproject) { 
    this.selectedproject = selectedproject;
    }  
  
    
 public List<SelectOption> getItems1() {
    
    List<SelectOption> options = new List<SelectOption>();
    
    options.add(new SelectOption('0','-None-'));
   // options.add(new SelectOption('AFEN','AFEN'));
    options.add(new SelectOption(''COO Circle'',''COO Circle''));
    options.add(new SelectOption('CFO Circle','CFO Circle'));
    options.add(new SelectOption('CMO Circle','CMO Circle'));
    options.add(new SelectOption('CSO Circle','CSO Circle'));
  //  options.add(new SelectOption('CTO Circle','CTO Circle'));
    
    return options;
}
*/
public List <Invite_tracking__c> getContacts() {
      c = null;
          c = [Select Organization__r.Name, Organization__r.Industry,  
               Organization__r.Operating_Group__c, Organization__r.Global_FT_500_Position__c, 
               Organization__r.Revenues_Mil_Value__c, Organization__r.US_Fortune_500_2009__c, Organization__r.NumberofEmployees,
               Organization__r.Client_Classification__c ,Contact__r.h_All_Feedback_Comments__c, 
               Contact__r.CAL_Approved_Name__c, Contact__r.CAL_Cell_Number__c, Contact__r.Name, Contact__r.CAL_Office_Number__c, 
               Contact__r.Client_Account_Lead__c, Contact__r.Date_Declined__c, Contact__r.Date_Identified_As_Target__c, 
               Contact__r.Date_Invite_Materials_Sent_to_PIE_CAL__c, Contact__r.Date_joined__c, 
               Contact__r.Date_of_CAL_Approval__c, Contact__r.Date_of_Exit__c, Contact__r.Dinner_Region__c, 
               Contact__r.EA_Email__c, Contact__r.Email, Contact__r.Executive_Assistant__c, Contact__r.Full_Name__c, 
               Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.MailingCountry, Contact__r.MailingState, Contact__r.Phone, Contact__r.MobilePhone, Contact__r.MailingPostalCode,
               Contact__r.Management_Link__c, Contact__r.Marketing_OG_Lead__c, Contact__r.Member__c, 
               Contact__r.PIE_Contact_CAL__c, Contact__r.Point_of_Contact__c, Contact__r.EA_Phone__c,
               Contact__r.Reason_for_Decline__c, Contact__r.Region__c,Contact__r.Title_Full__c, Contact__r.Direct_Line__c, Contact__r.Weblink_to_Bio__c, Contact__r.Member_Source__c, 
               Initial_Interview_Status__c, Interview_Time_Date__c, Interview_Conducted_by__c, Pre_PIE_Call_Name__c, 
               Pre_PIE_Status__c,Group_Call_Name__c, Group_Call_Status__c, Group_Call_Was_CAL_informed__c, 
               Small_Group_Call_Name__c, Small_Group_Call_Date__c, Small_Group_Call_Status__c, 
               Small_Group_call_Was_CAL_informed__c, Regional_Dinner_Date__c, Regional_Dinner_Status__c, 
               Summits_Date__c, Summits_Status__c, Regional_Roundtable_Date__c, Regional_Roundtable_Status__c, New_Member_Interview_Points__c, New_Member_Interview_Points_Possible__c, 
               Contact__r.Lead_Source__c, Member__c, Contact__r.Member_Invite_Ranking__c, Contact__r.Marketing_Contacts__c, New_Member_Interview__c, 
               Project__c, NMI_CAL_Initial_Interview_Status__c, Organization__r.Policy_1221_Company__c, 
               Organization__r.Competitor_Issue__c FROM Invite_Tracking__c  WHERE Project__c = 'COO Circle' order by Contact__r.Member_Invite_Ranking__c asc, Organization__r.name asc, Contact__r.name asc limit 750];
              return c;
              
         //  for( Invite_tracking__c it : c ) 
  }
 
  
       
    
}

 

<apex:page id="Page" showheader="true" sidebar="false" controller="dataTableContacts" standardstylesheets="false"  > 

<style>
.style16 {
    font-size: 10px;
    text-align: center;
    border-color: #000000;
    }
</style>

<apex:sectionHeader title="COO Invitation Tracking"/>
<apex:form >
   <apex:pageBlock >
     
      <apex:commandButton value="Print to Excel" action="{!save}"/>
   <br></br>
   <br></br>
     <apex:outputpanel id="out" layout="block" >
            
       
                            <apex:dataTable columnsWidth="1%,2%,2%,1.5%,20.5%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,1.5%,2%,1.5%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,2%,1.5%,1.5%,2%,1.5%,2%,1.5%,2%" value="{!Contacts}" var="c" border="1" style=" background-color: #C0C0C0; font-family: 'Arial';font-size:9px;  cellspacing:0 ;cellpadding:0; align:left"  >
                              <apex:column style="{!if(c.member__c='Community Member','background-color:#00FF00;text-align:centre; width:1%;',
                                                    if(c.member__c='Pending - Account Team - invite extended' || c.member__c='Pending - Account Team - contacted assistant' || c.member__c='Pending - Account Team - currently unable to reach','background-color:#FFFF00;text-align:centre;width:1%',
                                                    if(c.member__c='Pending - Centralized Process - contacted assistant' || c.member__c='Pending - Centralized Process - currently unable to reach' || c.member__c='Pending - Centralized Process - invite extended', 'background-color:#FFFF66;text-align:centre;width:1%',
                                                    if(c.member__c='Pending – Invite POC TBD', 'background-color:#FFFF99;text-align:centre;width:1%',
                                                    if(c.member__c='Declined', 'background-color:#FF0000;text-align:centre;width:1%',
                                                    if(c.member__c='Accenture opt-outs (legitimate)' || c.member__c='On hold','background-color:#FF9900;text-align:centre;width:1%',
                                                    if(c.member__c='Arbitrating - Account' || c.member__c='Arbitrating - Target','background-color:#FFCC99;text-align:centre;width:1%',
                                                    if(c.member__c='Approval Required - Existing Target' || c.member__c='Approval Required - New Target','background-color:#9E5ECE;text-align:centre;width:1%',
                                                    if(c.member__c='Currently Investigating','background-color:#FF99CC;text-align:centre;width:1%',
                                                    if(c.member__c='COO Circle Alumni','background-color:#99FF66;text-align:centre;width:1%',
                                                    if(c.member__c='Former Community Member','background-color:#B6DDE8;text-align:centre;width:1%',
                                                    if(c.member__c='No longer pursuing','background-color:#D8D8D8;text-align:centre;width:1%',
                                                    'background-color:grey'))))))))))))}">
                                    <apex:facet name="header">Rank</apex:facet>
                                    <apex:outputField value="{!c.Contact__r.Member_Invite_Ranking__c  }" style="font-weight:light; font-size:9px" />
                                </apex:column>
                                <apex:column style="{!if(c.member__c='Community Member','background-color:#00FF00;text-align:centre; width:1%;',
                                                    if(c.member__c='Pending - Account Team - invite extended' || c.member__c='Pending - Account Team - contacted assistant' || c.member__c='Pending - Account Team - currently unable to reach','background-color:#FFFF00;text-align:centre;width:1%',
                                                    if(c.member__c='Pending - Centralized Process - contacted assistant' || c.member__c='Pending - Centralized Process - currently unable to reach' || c.member__c='Pending - Centralized Process - invite extended', 'background-color:#FFFF66;text-align:centre;width:1%',
                                                    if(c.member__c='Pending – Invite POC TBD', 'background-color:#FFFF99;text-align:centre;width:1%',
                                                    if(c.member__c='Declined', 'background-color:#FF0000;text-align:centre;width:1%',
                                                    if(c.member__c='Accenture opt-outs (legitimate)' || c.member__c='On hold','background-color:#FF9900;text-align:centre;width:1%',
                                                    if(c.member__c='Arbitrating - Account' || c.member__c='Arbitrating - Target','background-color:#FFCC99;text-align:centre;width:1%',
                                                    if(c.member__c='Approval Required - Existing Target' || c.member__c='Approval Required - New Target','background-color:#9E5ECE;text-align:centre;width:1%',
                                                    if(c.member__c='Currently Investigating','background-color:#FF99CC;text-align:centre;width:1%',
                                                    if(c.member__c='COO Circle Alumni','background-color:#99FF66;text-align:centre;width:1%',
                                                    if(c.member__c='Former Community Member','background-color:#B6DDE8;text-align:centre;width:1%',
                                                    if(c.member__c='No longer pursuing','background-color:#D8D8D8;text-align:centre;width:1%',
                                                    'background-color:grey'))))))))))))}">
                                    <apex:facet name="header">Member Status?</apex:facet>
                                    <apex:outputField value="{!c.Contact__r.Member__c}" style="font-weight:light; font-size:9px" />
                                    </apex:column>
                                <apex:column style="{!if(c.member__c='Community Member','background-color:#00FF00;text-align:centre; width:1%;',
                                                    if(c.member__c='Pending - Account Team - invite extended' || c.member__c='Pending - Account Team - contacted assistant' || c.member__c='Pending - Account Team - currently unable to reach','background-color:#FFFF00;text-align:centre;width:1%',
                                                    if(c.member__c='Pending - Centralized Process - contacted assistant' || c.member__c='Pending - Centralized Process - currently unable to reach' || c.member__c='Pending - Centralized Process - invite extended', 'background-color:#FFFF66;text-align:centre;width:1%',
                                                    if(c.member__c='Pending – Invite POC TBD', 'background-color:#FFFF99;text-align:centre;width:1%',
                                                    if(c.member__c='Declined', 'background-color:#FF0000;text-align:centre;width:1%',
                                                    if(c.member__c='Accenture opt-outs (legitimate)' || c.member__c='On hold','background-color:#FF9900;text-align:centre;width:1%',
                                                    if(c.member__c='Arbitrating - Account' || c.member__c='Arbitrating - Target','background-color:#FFCC99;text-align:centre;width:1%',
                                                    if(c.member__c='Approval Required - Existing Target' || c.member__c='Approval Required - New Target','background-color:#9E5ECE;text-align:centre;width:1%',
                                                    if(c.member__c='Currently Investigating','background-color:#FF99CC;text-align:centre;width:1%',
                                                    if(c.member__c='COO Circle Alumni','background-color:#99FF66;text-align:centre;width:1%',
                                                    if(c.member__c='Former Community Member','background-color:#B6DDE8;text-align:centre;width:1%',
                                                    if(c.member__c='No longer pursuing','background-color:#D8D8D8;text-align:centre;width:1%',
                                                    'background-color:grey'))))))))))))}">
                                    <apex:facet name="header">Member Source</apex:facet>
                                    <apex:outputField value="{!c.Contact__r.Member_Source__c}" style="font-weight:light; font-size:9px" />
                                </apex:column>
                            </apex:dataTable>
               
                  </apex:outputpanel> 
             </apex:pageblockSection>
        </apex:pageBlock>
</apex:form>
</apex:page>

 

 

Thanks

 

Rudi

stephanstephan

One thing to note is that formula expressions contribute to view state. You've got some pretty wordy expressions in your column style attrbutes. What you may try, and would make your code more readable and maintainable to boot, would be to instead assign a styleClass, rather than an inline style. Then put your CSS rules in the class and include it in an inline style block on the page.

 

...stephan

incuGuSincuGuS

Rudi,

 

All styles should be done by a separate CSS block , inline styles can prove difficult to mantain and locate to fix it a problem arises, I would recommend styling the table through CSS selectors.

 

 

Also since the code is so customized and you have lots of fields and forumulas, i would suggest using an <apex:repeat> and rendering your table yourself, with the columns having classes, ids, etc whatever you need to make the CSS work.

And maybe simplifying some formulas by creating custom formula fields on the objects?

 

 

for example :

 

<table>
    <apex:repeat value="{!c}" var="contact">
       <tr>
           <td class="whatever {!IF(contact.value > 0,'otherclass','')}">
{!contact.whatever}
</td> <td class="whatever2">{!contact.whatever2}</td> <td class="whatever3">{!contact.whatever3}</td> <td class="whatever4">{!contact.whatever4}</td> </tr> </apex:repeat> </table>

 

 

You will have tons of fields to show, thats right, but this way is readable customizable as you want it to be. The downside to this is that you will have to style the table completely. But since this information is a lot (750 records) and lots of different styles i would suggest styling it yourself anyway to try and improve how it looks.