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
Walter@AdicioWalter@Adicio 

does use of the rendered attribute count heavy against the maximum view state size limit?

 

for example i have two pages both using the same controller. one page causes the max view state size error and the other does not.

 

the only difference between the two pages is the one causing the error has a lot of rendered attributes being used to switch between showing an outputfield and an inputfield on that same page.

 

also if anyone can point me to some info i can read about best practices for avoiding hitting the view state size limit that would be great.

sravusravu

try using Transient keyword in the controller.

Pradeep_NavatarPradeep_Navatar

The view state limit is not typically reached by Visualforce controllers except by long wizards which store a lot of state information. Declaring variables as transient reduces view state size. Use transient keyword to declare instance variables that cannot be saved, and should not be transmitted as part of the view state for a Visualforce page.

 

The syntax is like : Transient Integer cToal;

 

Hope this helps.

 

 

 

Walter@AdicioWalter@Adicio

thank you guys this does help. I have another question.

 

should i be creating two different lists. one list when i need to read the list, and a different list when i need to edit the list?

 

if i want to edit records in the list then this list is declared normally.

 

but after i save my edits and now i want to see the changes in a read only list then this list should be declared transient?

 

for example...

 

list<Contact> editContacts {get;set;}  .... display when i want to edit.

 

transient list<Contact> readContacts {get; set;}  .... display when i just want to read.

 

a side question... does viewstate size affect the page load time? So by using transient anywhere i can MAY reduce the page load time?

 

ive noticed in my page something as simple as changing a boolean is taking a really long time..

 

like this...

pageReference p(){
b = true;
return null;
}

 

especially the more records in the list the slower the loading.  so if the page i run this command from has less info in the view state the page may refresh faster?

 

 

thank you.