When a user views a Visualforce page, instances of the controller, extensions, and components associated
with the page are created by the server. The order in which these
elements are executed can affect how the page is displayed to the
user.
To fully understand the order of execution of elements on a
Visualforce page, you must first understand the page's
lifecycle–that is, how the page is created and destroyed during the
course of a user session. The lifecycle of a page is determined not
just by the content of the page, but also by how the page was requested.
There are two types of
Visualforce page requests:
- A get request is an initial
request for a page either made when a user enters an URL or when a
link or button is clicked that takes the user to a new page.
- A postback request is
made when user interaction requires a page update, such as when a
user clicks on a Save button and triggers a
save action.
For specific details of the two types of requests, examples illustrating
the lifecycle of a page, and tips on how to handle execution order
when writing your own custom controllers and controller extensions,
see: