Newer Version Available

This content describes an older version of this product. View Latest

Setting for Controller Methods for Controller Methods

Visualforce controller methods can, with some important limitations, use the Apex ReadOnly annotation, even if the page itself isn’t in read-only mode.
Visualforce controller methods with the @ReadOnly annotation automatically take advantage of read-only mode.. However, restrictions on the @ReadOnly annotation means that, for Visualforce controller methods, a read-only method must also have the @RemoteAction annotation. The @RemoteAction annotation requires that the method be:
  • Either global or public
  • static

Enabling read-only mode. by using the @ReadOnly annotation must be done on the top level method call. If the top level method call doesn’t have the@ReadOnly annotation, the normal restrictions on maximum queried rows are enforced for the entire request, even if secondary methods are annotated with @ReadOnly.

Using the @ReadOnly annotation on a controller method allows you to retrieve a larger collection of records as the result of a Visualforce expression. However, it doesn’t increase the maximum number of items in a collection for iteration components. If you want to iterate over larger collections of results, you need to enable read-only mode. for the entire page.