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}"/>

Controller:

public boolean val {get;set;}

method(){

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:actionRegion>

    <apex:inputField value="{!TestValue}" > 

        <apex:actionSupport event="onchange" rerender="Id1,Id2,Id3,Id4" action="{!TestMethod}" >

            <apex:param name="Para" value="{!rowNum}" assignTo="{!IndexValue}" />

        </apex:actionSupport>

    </apex:inputField> 

</apex:actionRegion>

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">

Comments

Popular Posts