You need to sign in to do that
Don't have an account?
Where should i consider to use view state or just transfer the Id and everytime i need to work on a record i bring values into transient variables
hi, I am new to salesforce, was given a dummy project as training purpose after reading about view state and execution order, context,etc. i am a bit confused about how to save the state(as with static vairables) through multiple request to the Server, i can be mistaking but that's what i got till now,
static vars can't be used because, HTTP, being stateless, removes them after every request in the VFpage
can use view state but that would increase transmission lag, can use transient variables(to have one non-transient "id" variable and retreieve rest of the record fields), but that would require querying everytime a user makes database request,
can anyone tell me when to consider using the transient variable method and when view state?? Thanx
Basically ,View State is an encrypted, hidden <input> field on a Visualforce page that keeps track of Apex controller state & Visualforce page state between server requests. This field is only generated when there is an <apex:form> tag present on a page.
ViewState is only used on a single page that handles postbacks. Once you redirect to the new page, the ViewState is lost.
The Whole Process of Calling is like this :
A. URL Requested
B. Apex Controller Instantiated on Server
C. Controller State Serialized & Encrypted to View State
D. Page Markup Sent to Browser & Rendered
E. View State Decrypted & Deserialized (for Postbacks)
View State Automatically keeps track of field values for you and Allows for easy AJAX functionality. In order to remove View State Error we use 4 methods.
A. Reduce Number of Components
B. Use the transient Keyword
C. Use JavaScript Remoting
D. Use the Streaming API
Declare only those fields as transient which values you dont need in visualforce page.
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
sfdcmonkey.com
In other words, the view state is first restored into memory (deserialized), and since accountName wasn't stored in the view state (it is transient), the initial value is null. Then, Visualforce calls set(accountName, value), because it's bound to a rendered input element, which effectively restores its state. Finally, save() is called and the value is correctly populated.