Tuesday, 2 January 2018

transient in Salesforce

What is transient?

transient is a keyword in Salesforce.

What is the use of transient ?

Use the transient keyword to declare instance variables that can't be saved, and shouldn't be transmitted as part of the view state for a Visualforce page.

What is View State ?

http is stateless protocol,To maintain the state between post backs View State is used.


What is the size of View State ?

Since it transfers over http every request ,The size should be controlled.
View State can be 135 KB.
Only one View state will be created per page.

transient variables can be serialized?

No

transient vs static ?

Both transient & static variables are not Serializable ,From this confusion starts.
Ideally both are 2 different concepts.

Static variables are not bound to any particular object,Its class level.Serialization based on object hence static variable are not serializable.

Transient variables are used when any instance variable need to be excluded from Serialization.







No comments:

Post a Comment