3

I have one vf page in which I have a requirement to display huge data but as we know Vf page has View state Limit as 135 KB , hence after reaching this Limit salesforce throws Exception as "Maximum view state size limit (135KB) exceeded". So I have to show a custom Message on VF page when this limit is exceeded. Is there any way to check this limit in code? or way to throw a custom message after limit is exceeded. Thnaks In Advance.

1
  • 2
    You typically know the list size when your page explodes.So check size of the list and populate message and clear the list to avoid view state error . Jan 3, 2015 at 8:59

2 Answers 2

1

You should take a look at following article:

Introduction to Visualforce View State

The use of transient keyword will allow you to minimize the Viewstate. Though, technically there is no known way to calculate Viewstate in visualforce via Salesforce Apex API, we just need to code within the best practices boundaries and that usually make sure that Viewstate issues never arise, also as @Mohith mentioned, clearing of Variables/List variables or variables specifically of blob datatype (file upload controls), also minimizes Viewstate by a good margin.

1

Please see the answer I posted to best-practices-for-custom-controller-actions which includes a summary of view state and what impacts it most when optimizing custom controllers. In particular there's a reference to an excellent webinar on Advanced Visualforce by @PBattison that should be available for viewing any day now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .