function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashritha ReddyAshritha Reddy 

how can reduce viewstate using action region?

how can reduce viewstate using action region?
Vasani ParthVasani Parth
I hope you already tried stuff mentioned here 

https://developer.salesforce.com/page/An_Introduction_to_Visualforce_View_State 

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices_performance.htm

Few quick ways that might help are 
  • Add transient keyword before variables, like lists used just for printing the tables.
  • Try recreating state, by querying again the database, storing in local lists, sets or maps will not work.
  • Declare some variable as static if possible, create static code block to recreate them in each request. 
  • Check your SOQL queries, if you are querying additional fields, never used or required on visualforce pa
Please mark this as the best answer if this helps







 
Amit Chaudhary 8Amit Chaudhary 8
Action Regions require a reRender attribute to be effective. The point of an Action Region is to refresh only part of the page, using only the data that is contained in the Action Region. This is commonly used to isolate apex:inputFile fields, which can't be used with reRender at all, and also to avoid validation errors that may occur while trying to update the page while some standard validations exist in the page.

If you have identified a use for an Action Region, you must also be prepared to use reRender, because the two work hand-in-hand. When you do not use a reRender attribute, the entire page state is submitted and validated before attempting to run any controller logic. Using the Action Region will restrict validation to just that section of the page, but also usually prevents updates from occurring outside the action region area.

Traditionally, I've used this to do things like loading a contact's address fields into the page when the contact is changed in a lookup field. Validation rules could prevent this code from running successfully, and so the Action Region serves as a way to isolate part of the page and allow the controller to run normally when it otherwise would produce Visualforce errors.

1) http://salesforce.stackexchange.com/questions/44935/apexactionregion-understanding


Please check below post As well
1) https://developer.salesforce.com/docs/atlas.en-us.salesforce_visualforce_best_practices.meta/salesforce_visualforce_best_practices/pages_best_practices_perf_code_view_state.htm
2) https://developer.salesforce.com/page/An_Introduction_to_Visualforce_View_State

Minimize Number of Forms on a Page
With the introduction of Single View State in the Summer '12 release, a Visualforce page manages a single view state, even when the page contains multiple input forms. Though developers should still try and avoid using multiple form elements as recommended in the following section, it no longer has any bearing on the size of the View State for a Visualforce page.


Assume a page contains two forms - form 1 and form 2. Whichever form the user submits and causes a postback, the view state for the page needs to get transferred. To support this, each form on your page will have its own copy of view state. If the associated view state is large, instead of having multiple forms on a page, have a single form and use <apex:actionRegion> to submit portions of the form. This practice will ensure that only a single copy of the view state is associated with that page. In the example below, two forms are used to update Account fields and the related Contact attributes.
// Using two forms
<apex:page controller="MyController">

<apex:form>
   <apex:commandButton action="{!saveAccount}" value="Update Account"/>
    <!--Account attributes available for editing -->

</apex:form>

<apex:form>
    <apex:commandButton action="{!saveContacts}" value="Update Contacts"/>
     <!--Contact attributes available for editing -->
</apex:form>

</apex:page>

These two can be combined into a single form by leveraging the <apex:actionRegion> component.
// Combining into single form and leveraging <apex:actionRegion>
<apex:page controller="MyController">
  <apex:form>
     <apex:commandButton action="{!saveAccount}" value="Update Account"/>
     <!--Account attributes available for editing -->
   
     <apex:actionRegion>
       <apex:commandButton action="{!saveContacts}" value="Update Contacts"/>
     <!--Contact attributes available for editing -->
    </apex:actionRegion>

  </apex:form>
</apex:page>


Multiple forms in a single VisualForce page
https://th3silverlining.com/2009/10/19/multiple-forms-in-a-single-visualforce-page/

Let us know if this will help you