I am trying to implement a page that I will upload files through it, but I keep having this error
Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 158.328KB
Here is my visualforce form
<apex:pageBlockSection columns="3">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Description" for="description"/>
<apex:inputTextarea value="{!document.description}" id="description"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!upload}" value="Upload"/>
</apex:pageBlockButtons>
and here is my APEX code
public List<Document> documents{set;get;}
public Document document
{
get
{
if (document == null)
document = new Document();
return document;
}
set;
}
document.AuthorId = UserInfo.getUserId();
document.FolderId = account.ID;
try {
insert document;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error'));
} finally {
document.body = null;
document = new Document();
documents = [SELECT Query];
}
What is the problem here ?
Update: The query was like this
documents = [SELECT Description, body, Id, Name, Url FROM Document WHERE
AuthorId =:UserInfo.getUserId()];
but it works after I removed body
documents = [SELECT Description, Id, Name, Url FROM Document WHERE
AuthorId =:UserInfo.getUserId()];