0

I am getting below error when i am trying to upload document in visualforce page.the page is very huge.Current view state before uploading the doucment is 87 kb.Please help me.

"Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 244.641KB

<apex:page standardController="ENT_ED_LIHTC__c" extensions="TstDocHub_LIHTCDeal_Checklist_Controller" sidebar="false" showHeader="false" action="{!FillNode}">
    <head>
        <script>
            function removeLine(Id)
            {
                var a = confirm('Do you really want to remove this section? If the answer is "Yes" then click "OK"');
                if(a)
                {
                    document.getElementById(Id).style.display='inline';
                    removeSec(Id);
                }
                else 
                {
                    return false;
                }
            }
            function removeSingleLine(Id,Str)
            {
                var a = confirm('Do you really want to remove this document? If the answer is "Yes" then click "OK"');
                if(a)
                {
                    document.getElementById(Str).style.display='inline';
                    removeDc(Id,Str);
                }
                else 
                {
                    return false;
                }
            }
        </script>
    </head>
    <style>

    </style>
    <!--<ul id="tree">
        <apex:repeat value="{!Nodes}" var="mainnode">
            <li><strong><apex:outputtext style="color:blue;" escape="false" value="{!mainnode.Parent}"/></strong>
            <ul>
                <apex:repeat value="{!mainnode.Child}" var="mm">
            <li><span><apex:outputtext style="color:green;" escape="false" value="{!mm['Subtype__c']}"/></span></li>
        </apex:repeat>
            </ul>
            </li>
                </apex:repeat>
    </ul>-->
    <apex:form >
        <apex:actionFunction action="{!FillNode}" name="Fill" status="stat" reRender="spanel"/>
        <apex:actionFunction name="removeSec" action="{!RemoveSection}" status="stat1" reRender="spanel" oncomplete="javascript:window.location.reload()">
            <apex:param name="sec" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="removeDc" action="{!RemoveDoc}" status="stat1" reRender="spanel" oncomplete="javascript:window.location.reload()">
            <apex:param name="DocName" value="" />
            <apex:param name="typeName" value="" />
        </apex:actionFunction>
        <apex:pageblock >
            <apex:pageBlockButtons >
                <!--<apex:commandButton value="Edit" action="{!EditNA}" reRender="spanel" status="stat" rendered="{!showButton}"/>
                <apex:commandButton value="Save" reRender="spanel"   action="{!NADocs}" status="stat" rendered="{!showButton}"/>-->
                <input type="button" value="Checklist Report" class="btn" onclick="window.open('/00Oa0000007eDkE?pv0={!TempProject.Name}&pv1={!TempProject.Id}','_blank')" />
                <apex:actionStatus id="stat">
                <apex:facet name="start">
                    <img src="/img/loading24.gif"/>
                </apex:facet>
                </apex:actionStatus>
                <!-- <input type="button" value="Print As Pdf" class="btn" onclick="window.open('https://enterprise--content--c.cs1.visual.force.com/apex/PrintableVersion?id={!$CurrentPage.parameters.id}','bla','width=800,height=600,menubar=1,toolbar=1');"/>
                <apex:commandButton value="Print as PDF" id="targetName" onclick="javascript:windows.location('www.google.com');" />-->
            </apex:pageBlockButtons>
            <apex:outputPanel id="spanel">
                    <apex:repeat value="{!Nodes}" var="nn" >
                    <apex:commandButton value="Edit All" action="{!EditNA}"  status="stat" rendered="{!showButton}"/>
                    <apex:commandButton value="Save All"   action="{!NADocs}" status="stat" rendered="{!showButton}"/>
                       <apex:pageblockSection title="{!nn.Parent}" showHeader="{!IF(nn.Parent=='',false,true)}" columns="1" id="node" collapsible="false">

                            <!-- <apex:repeat value="{!nn.Child}" var="cc">-->
                            <apex:panelGrid columns="2" cellspacing="3">
                                <apex:panelGroup >
                                    <div style="margin-top:5px;">
                                    <apex:outputText value="{!nn.TChild}" escape="false" style="font-weight:bold; height:30px"/>
                                    </div>
                                </apex:panelGroup>
                                <!--<apex:actionStatus id="stat1">
                                <apex:facet name="start"></apex:facet>
                                <apex:facet name="stop">-->
                                <input type="button" class="btn"   value="Remove"  onclick="removeLine('{!nn.TChild}')"   style="display:{!IF(AND(nn.TChild!=null,showButton==true),'inline;','none;')}"/>
                                <img src="/img/loading24.gif" id="{!nn.TChild}" style="display:none;"/>
                            </apex:panelGrid>
                            <apex:pageBlockSectionItem >
                                <apex:pageblockTable value="{!nn.DocType2}" var="dt">
                                     <apex:column >                                      
                                          <apex:commandLink Value="Edit" action="{!allowEdit}" style="font-weight:bold"  status="stat" rendered="{!IF(dt.isEditMode==true,false,true)}">             
                                                <apex:param name="param2" value="{!dt.itemProject.Id}" assignTo="{!editRecordId}"/>
                                         </apex:commandLink>

                                         <apex:commandLink Value="Save" action="{!saveRecord}" style="font-weight:bold"  status="stat" rendered="{!IF(dt.isEditMode==true,true,false)}" >
                                               <apex:param name="param3" value="{!dt.itemProject.Id}" assignTo="{!editRecordId}"/>
                                         </apex:commandLink> 
                                         {!message}
                                     </apex:column>
                                    <apex:column headerValue="Uploaded" >
                                        <apex:Image value="{!IF((dt.itemProject.Uploaded_Project_Documents1__r.size>0 || dt.na==true) ,$Resource.Uploaded,$Resource.Notuploaded)}"/>
                                    </apex:column>
                                    <apex:column headerValue="N/A Status">
                                        <apex:inputCheckbox value="{!dt.na}" id="na" 
                                        disabled="{!IF(DisplayNA==true || dt.isEditMode==true,false,true)}"                             
                                        onclick="if(this.checked){document.getElementById(this.name.replace('na','pc')).checked = false;}" />
                                    </apex:column>
                                    <apex:column headerValue="PC">
                                        <apex:inputCheckbox value="{!dt.pc}" id="pc"
                                        disabled="{!IF(DisplayNA==true || dt.isEditMode==true,false,true)}" 
                                        onclick="if(this.checked){document.getElementById(this.name.replace('pc','na')).checked = false;}" />
                                    </apex:column> 
                                    <apex:column value="{!dt.itemProject.Type_Number__c}"/>
                                    <apex:column value="{!dt.itemProject.Name}"/>
                                    <apex:column headerValue="Upload Document">

                                      <!--<apex:inputFile title="Choose a file up to 10MB" id="file" value="{!FileBody}" fileName="{!filename}"  tabindex="1"/>
                                        -->                                          
                                         <apex:inputFile title="Choose a file up to 10MB"  value="{!dt.cl.FileBody}"  disabled="{!IF(DisplayNA==true || dt.isEditMode==true,false,true)}" fileName="{!dt.cl.ContentToUpload.PathOnClient}" tabindex="1"/>
                                    </apex:column>                                
                                    <apex:column headerValue="Document Link">
                                    <apex:repeat value="{!dt.itemProject.Uploaded_Project_Documents1__r}" var="cc">
                                        <br>
                                        <!--<a target="_blank" href="/{!cc.Content_Id__c}">{!cc.Title__c}</a></br>-->
                                        <apex:outputLink target="_blank" value="/{!cc.Content_Id__c}" rendered="{!IF(cc.Content_Id__c != null,true,false)}">{!cc.Title__c}</apex:outputLink></br>
                                    </apex:repeat>
                                        </apex:column>  

                                    <apex:column headerValue="Document Status">
                                        <apex:repeat value="{!dt.itemProject.Uploaded_Project_Documents1__r}" var="cc">
                                           <apex:outPutField value="{!cc.Status__c}" 
                                           rendered="{!IF((DisplayNA==false && dt.isEditMode==false) || cc.Status__c == 'Not Applicable' || cc.Status__c == 'Post Closing' ,true,false)}" /><br/>
                                           <apex:InPutField value="{!cc.Status__c}"  
                                           rendered="{!IF((DisplayNA==true || dt.isEditMode==true)&& cc.Status__c != 'Not Applicable' && cc.Status__c != 'Post Closing',true,false)}" />                                          
                                        </apex:repeat>                                      
                                    </apex:column>

                                    <apex:column headerValue="Comments">
                                        <apex:repeat value="{!dt.itemProject.Uploaded_Project_Documents1__r}" var="cc">
                                              <apex:outPutField value="{!cc.Comments__c}" 
                                              rendered="{!IF(DisplayNA==false && dt.isEditMode==false,true,false)}"/>
                                              <apex:InPutField value="{!cc.Comments__c}"  
                                              rendered="{!IF(DisplayNA==true || dt.isEditMode==true,true,false)}"/> 
                                        </apex:repeat>
                                    </apex:column>

                                    <apex:column >
                                        <apex:actionStatus id="stat2">
                                        <apex:facet name="start">
                                            <img src="/img/loading24.gif" />
                                        </apex:facet>
                                        <apex:facet name="stop">
                                            <!--<apex:commandButton status="stat2" reRender="spanel" value="Remove" rendered="{!IF(AND(nn.TChild==null,$Profile.Name=='System Administrator'),true,false)}" action="{!RemoveDoc}" oncomplete="javascript:window.top.location='/{!TempProject.id}'">
                                            <apex:param name="param2" value="{!dt.itemProject.Name}" assignTo="{!DocName}"/>
                                            <apex:param name="param1" value="{!nn.Parent}" assignTo="{!typeName}"/>
                                            </apex:commandButton>-->
                                        </apex:facet>
                                        </apex:actionStatus>
                                        <!--<input type="button" class="btn"   value="Remove"  onclick="removeSingleLine('{!dt.itemProject.Type_Number__c}','{!nn.Parent}')"   style="display:{!IF(AND(nn.TChild==null,showButton==true),'inline;','none;')}"/>-->
                                        <input type="button" class="btn"   value="Remove"  onclick="removeSingleLine('{!dt.itemProject.Type_Number__c}','{!nn.Parent}')" style="display:{!IF(AND(nn.TChild==null,showButton==true),'inline;','none;')}"/>
                                        <img src="/img/loading24.gif" id="{!nn.Parent}" style="display:none;"/>
                                    </apex:column>
                                </apex:pageblockTable>
                            </apex:pageBlockSectionItem>
                        </apex:pageblockSection>
                    </apex:repeat>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
    <script>
        //window.setTimeout(Fill,1000);
    </script>
</apex:page>

enter image description here

Rao
  • 16,691
  • 13
  • 68
  • 108
sfdc
  • 13,663
  • 18
  • 129
  • 216
  • To find where your resources are being eaten up enable Show View State in Development Mode in your user profile and see if there is a particular collection that is gobbling all the view state. without the controller code we cannot say what collection elements are being used in your code. – Rao Sep 12 '13 at 20:28
  • i am not able to add controller code to post as it exceeded the limit..where do u want me to post the code – sfdc Sep 12 '13 at 20:32
  • If your controller is so big then all that i can recommend is load the page and check the view state and see where the collection limit is exceeding. – Rao Sep 12 '13 at 20:35
  • Internal ..65 kb and controller part is 24 kb – sfdc Sep 12 '13 at 20:38
  • 2
    Try to make your list transient but you might need to change your code then. – brovasi Sep 12 '13 at 20:40
  • Whatever doesn't need persistence should be marked as transient. – Mike Chale Sep 12 '13 at 20:44
  • @kiran Which approach you are using? I think I have answered previously on you post about uploading document from visualforce page. http://salesforce.stackexchange.com/questions/16486/upload-functionality-in-visualforce-page/16489#16489 – Ashwani Sep 13 '13 at 07:35

0 Answers0