O'Reilly logo

Visualforce Developer's Guide by W.A.Chamil Madusanka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the transient keyword

The transient keyword is used for declaring variables, and is used in Apex classes. Declaring a variable as transient reduces the view state size. Variables with the transient keyword cannot be saved and should not be transmitted as a part of the view state of the particular Visualforce page. Transient variables are needed only for the duration of a page request.

The transient keyword is used in a serializable Apex class, which means the classes that implement the Batchable or Schedulable interfaces. The following Apex objects are natively considered as transient:

  • PageReference
  • XmlStreamClasses
  • Collections (only if the type of object that they hold is automatically marked as transient)
  • Most objects generated by system methods ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required