Difference between rendered, renderAs and reRender in Visualforce Page

Rendered : It’s a Boolean value and the default value is always true, It works like “display” property of CSS. It is used to place condition for a component(field, outputpanel, section etc), that will show or not on page. (If it is true, it displays the block else it will be hidden).

For Example:
Visualforce Page:
In the controller we need to have get method to assign the value for this variable.

<apex:inputField value="{obj.Filed__c}" Rendered="{!val == true}"/>


public boolean val {get;set;}

val = true;

Rerender: After Ajax which component should be refreshed. For this we need to assign id to field, sections or a block. It’s available on commandlink, commandbutton, actionSupport etc.

For Example:
Visualforce Page:

    <apex:inputField value="{!TestValue}" >   
        <apex:actionSupport event="onchange" rerender="Id1,Id2,Id3,Id4" action="{!TestMethod}" >
            <apex:param name="Para" value="{!rowNum}" assignTo="{!IndexValue}" />

Here in actionSupport rerender attribute Id1,Id2,Id3,Id4 are the id’s of field and sections.

RenderAs: It is used for visualforce page show as pdf, excel or any other standard document format.

For Example:
Visualforce Page:

<apex:page controller="TestController" rederAs="pdf">

Leave a Reply