render and rerender in salesforce

Article 1** Article 2** Article 3** Article 4** Article 5** Article 6** Article 7** Article 8** Article 9  ** Article 10

Let us try to understand Rendered, ReRender and RenderAs in visualforce: 


A visualforce component in a vf page can be displayed or hidden by using rendered attribute. Rendered is bound to a boolean variable in controller which can be switched between true and false making the vf component display or hide depending on boolean value.

As an example:

                                   visualforce page


Here lower page block is given rendered that is bound to a boolean variable "ShowpageBlockFlag". Initially (in constructor) this variable is set to false which hides the lower page block.

Once we click the command button, "ShowBlockMethod" method is called where this boolean is set to true and hence the lower page block gets displayed.


Rerender is used to refresh a particular section of the visualforce page. We have to just mention the id of the page section (in the Rerender attribute) that needs to be refreshed.

In the follwoing example Clicking of the command button "Refresh Lower Page Block" refreshes the lower page block.

                                               Visualforce page                     


Initially when the page is loaded the output string value is set in constructor as "Test value set in constructor".'

When the button is pressed method "ShowBlockMethod" is called where "OutPutString"  value is changed also lower page block is refreshed and hence the new value is displayed in the lower page block.

rerender="pgblckID" statement in command button indicates that the page block section with id ="pgblckID" should be refreshed when button is pressed. Only Lower page block is refreshed rest of the page remains as it is.

A single Rerender attribute could be used to refresh many sections of the page. For example: reRender= "pgblck1, pgbcl2"


This is used with page component and renders the page in the specified format. Currently only pdf format is supported.

Following page will give output in pdf form /render as pdf.

                              Visualforce page

Article 1** Article 2** Article 3** Article 4** Article 5** Article 6** Article 7** Article 8** Article 9 ** Article 10

Click For : Salesforce Interview Question And Answers


  1. Simple and Superb! Well explained Mr. Gadekar.

  2. Well Done... for last two days, I am going through your post and all are very simple and well explained..

  3. very nice job! very simple to follow! thanks for sharing Mr. Gadekar.

  4. thanks,well explained..

  5. superb ....... could you please share you skype id or any other communication id.

  6. Simple with easy to understand explanation and examples. Appreciate your effort.

  7. Simple explaination making it to understand everyone...Thanks You

  8. very simple and easy to understand code for beginners.. Looking forward to see your video tutorial in youtube :)..
    Thanks alot Mr.Gadekar

  9. Excelent Example, thank you very much... 10/10

  10. Great Post and good explanation .....could you please post more examples on different topics like multiple extensions with single standard or custom controller ..Thank you in advance ....I am eagerly waiting for other posts...:)

  11. Excellent post!