Activity Forums Salesforce® Discussions What is the difference between Render, Rerender And RenderAs attributes of Visualforce?

  • Anurag

    Member
    July 27, 2018 at 12:36 pm

    Hi Sanjana,

    Rendered-This attribute is used to display a particular filed or section based on boolean value.

    ReRender- This is to reload some fields, or sections after some operation. Advantage of it is that the whole page is not refreshed and only a portion(the one which is ReRendered) is refreshed.

           RenderAs- This is to render a VF page as PDF or some other format.

     

  • Parul

    Member
    September 14, 2018 at 4:57 am

    Rendered Attribute :-

    The rendered attribute is a Boolean value, it has true as default value and based on the value it will show or hide a page block or a field on the VF pages.

    rendered= "true or flase"

    Rerender Attribute :-

    Rerender Attribute is used to refresh particular section on page to update latest data received from salesforce after action method call is done. You need to give the id of page section in attribute as shown below

    rerender = "pageblockId"

    Renderas Attribute :-

    If you want to render your page as PDF, so this is the right option to go ahead with it and most importantly only PDF is the supported content converter. Setting this Renderas attribute to “pdf” renders the page as a PDF.

    Renderas= "pdf"

     

    Thanks

  • shariq

    Member
    September 14, 2018 at 6:19 am

    Hi,

    Render: – Is used to show/hide the particular block, output panel or input/output fields based on the condition.

    Example: – You have 2 fields one is visible and second is hidden, you want the second field to be visible when the first field is filled then use render.

    <apex:pageBlockTable value=”{!empList}” var=”emp” rendered=”{!empList.size > 0}”>
    <apex:column value=”{!emp.Name}”/>
    </apex:pageBlockTable>

    reRerender: – Is used to refresh the particular output panel, block, and or fields after a server request has been completed. It uses Id to reRender.

    Example: – You have a VF page where you want to add Contacts related to Account and also wanted to show the recently added Contacts then use reRender to refresh the block which is showing the contact list.

    renderAs: – Is used to open the Visualforce Page in different format like- HTML, pdf, and excel

    Example: – To show the invoice in PDF format.

    for pdf – renderAs =”pdf”

    for HTML – renderAs =”html”

    for excel – <apex:page controller=”contactquery” contentType=”application/vnd.ms-excel#SalesForceExport.xls” cache=”true”>

    Hope this helps!

  • Avnish Yadav

    Member
    September 14, 2018 at 1:39 pm

    Hello,

    Rendered: 

    This to rendered(ie., display) particular filed or section based on boolean value.  In the controller you need to have get method to assign the value for this variable.

    Eg:
    `

    `
    controller:
    `
    public boolean val{get;set;}

    method(){
    val = true;
    }
    `
    RederAs:

    It is render a VF page as PDF or some other

    Eg:
    `

    `
    ReRender:

    This is to ReReder(ie.,Reload) some fields, or sections  after some operation/change. For this you need to assign id to field, sections.

    Eg:

    <apex:actionRegion >
    <apex:inputField value="{!xxxx}"  >
    <apex:actionSupport event="onchange" rerender="id1,id2, id3" action="{!xxx}" >
    <apex:param name="Para" value="{!rowNum}" assignTo="{!IndexValue}" />
    </apex:actionSupport>
    </apex:inputField>
    </apex:actionRegion>
    </apex:inputFiel>

    id1,id2, id3  are the id's of field and sections

Log In to reply.

Popular Salesforce Blogs