You need to sign in to do that
Don't have an account?
view state size exceeded - any ideas?
i'm trying to upload some files and store these on the controller and eventually send these. The error i get back is "Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 772.562KB". I need to be able to be able to store some blobs (upto 5mb of files extracted from attachments, files on c: and documents) on the controller, but the view state size seems to preclude this. The following is the simplest possible code to illustrate the problem at hand (a file is select, the savex operation causes bound variables to load, the page refreshes and exceeds limits) and a solution to this would enable me to address my actual code (too long to post). I would appreciate any help that could be given.
thank you.
public withsharingclass docController {
public document document {get; set;}
public docController() {
document =new document();
}
publicvoid savex() { }
}
<apex:page controller="docController"> <apex:messages />
<apex:form id="theForm"> <apex:pageBlock >
<apex:pageBlockSection > <apex:inputFile value="{!document.body}" filename="{!document.name}"/> <apex:commandButton value="Save" action="{!savex}"/>
</apex:pageBlockSection> </apex:pageBlock>
</apex:form>
</apex:page>
Refer : http://forceguru.blogspot.com/2010/11/best-practise-to-write-apex.html
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
All Answers
Hi,
This is a duplicate post please make sure that you do not post any duplication questions on discussion board. So I request you to please remove it. For information regarding this post you can go to the following link:
http://boards.developerforce.com/t5/General-Development/view-state-size-exceeded-any-suggestions/m-p/424289/highlight/false#M68882
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Refer : http://forceguru.blogspot.com/2010/11/best-practise-to-write-apex.html
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
tried using transient earlier. The code had been working for small attachments, but adding the transient keyword to the instance variable (list storing the attachments) caused a null pointer exception. It seemed to lsot it's value between the controller constructor and the subsequent methods - but only when declared using transient.
a closer look at transient methods offered some insight into the nature of the problem (how state is stored). It seems likely what i had hoped to achieve is impossible. Thanx Chamil and Ankit for the assistance.
Hello all,
I am trying to use transient for attachment, but when I am saving it, it is showing me "Null" in Attachment Name and Attachment Body. If I am not using transient, I can store the attachment only upto a size of 135Kb. But we can actually store upto 5MB in developer edition.
And is there is way to catch the "Maximum view state size limit (135KB) exceeded." exception.
Best Regards
You need to set attachment.Body = null after you save it to the database. If you don't, it is part of view state size.