VF Page Postback Requests Execution Order

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. 
The following diagram shows how a Visualforce page interacts with 
controller extension or a custom controller class 
during a postback request:

A diagram of how a Visualforce page interacts with a controller extention or a custom controller class during a postback request

  1. During a postback request, the view state is decoded and used as the basis for updating the values on the page.
    A component with the immediate attribute set to true bypasses this phase 
    of the request. In other words, the action executes,but no validation 
    is performed on the inputs and no data changes on the page.
  2. After the view state is decoded, expressions are evaluated and set methods on the controller and any controller extensions, including set methods in controllers defined for custom components, are executed.
    These method calls do not update the data unless all methods are executed successfully. For example, if one of the methods updates a property and the update is not valid due to validation rules or an incorrect data type, the data is not updated and the page redisplays with the appropriate error messages.
  3. The action that triggered the postback request is executed. If that action completes successfully, the data is updated. If the postback request returns the user to the same page, the view state is updated.
    The action attribute on the <apex:page>component is not 
    evaluated during a postback request. It is only evaluated 
    during a get request.
  4. The Resulting HTML is sent to the browser.
    If the postback request indicates a page redirect and the redirect is to a page that uses the same controller and a proper subset of controller extensions of the originating page, a postback request is executed for that page. Otherwise, a get request is executed for the page. If the postback request contains an <apex:form>  component, only the ID query parameter on a postback request is returned.

    You can use the setRedirect attribute on a pageReference to control whether a 
    postback or get request is executed. If setRedirect is set to true, a get request 
    is executed. Setting it to false does not ignore the restriction that a postback 
    request will be executed if and only if the target uses the same controller and a 
    proper subset of extensions. If setRedirect is set to false, and the target does 
    not meet those requirements,a get request will be made.
  5. Once the user is redirected to another page, the view state and controller objects are deleted. For a specific example of a postback request, see Examples of Visualforce Page Execution Order.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s