5

I am looking into 'View State Limit exceeded' error and want to display the View state information using the development mode footer. For my user, I have enabled both Development Mode and Show View State in Development Mode.

At the moment, I cannot get the View State to appear. The page does contain <apex:form> tags but is using a standardController.

By using a Standard Controller, does this mean I cannot get the View State information I need?

Since the view state is linked to form data, the View State tab only appears if your page contains an <apex:form> tag. In addition, the View State tab displays only on pages using custom controllers or controller extensions. Link

Does anyone know any other way around this?

1 Answer 1

2

What the message states is that you need some custom Apex code for the page to bother serializing the View State and sending it to the server. There are two ways to do so.

  1. Use a standard controller with a controller extension.
  2. Use a custom controller.

If you are using a StandardController already, you would write an Extension. The Visualforce Developer Guide has a great article on Building a Controller Extension. In essence, you need to write a class that accepts the StandardController as a parameter in its constructor, then add it to the extensions property of your <apex:page> tag.

Extension

public with sharing class MyExtension
{
    public MyExtension(ApexPages.StandardController controller)
    {
        // constructor logic if necessary
    }
}

Page

<apex:page standardController="..." extensions="MyExtension">
    <!-- additional markup -->
</apex:page>

Note that the property is plural. You can add more than one extension to a page.

I also highly recommend you read Difference between controller and extensions. It's one of the better answers anywhere on this forum.

3
  • Thank you for the response. I have created an extension class and am adding it to my page. I am also certain at this point I should be able to see the View State.
    – TSmith
    Oct 13, 2016 at 14:22
  • Are you aware of any known issues based on browsers preventing the View State?
    – TSmith
    Oct 13, 2016 at 14:23
  • I'm not even sure that's technically possible. Certainly not without some hack-y browser extensions.
    – Adrian Larson
    Oct 13, 2016 at 14:24

You must log in to answer this question.

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