What are Rendered, Rerender, RenderAs Attributes in Lightning Components?

What are Rendered, Rerender, RenderAs Attributes? | Salesforce Guide

Let us learn about Rendered, ReRender, and RenderAs attributes:

Rendered

This attribute is used to display a particular field or section based on Boolean value. 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, use rendered= "true or false".

The Render attribute is also used to show/hide the particular block, output panel or input/output fields based on the condition. For 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>

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. The 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, rerender = "pageblockId".

It’s available on commandlink, commandbutton, actionSupport etc. 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. For 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. 

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

dont miss out iconDon't forget to check out: Visualforce in Lightning Experience | Salesforce Guide

RenderAs

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. If you want to render your page as PDF, then follow, Renderas= "pdf".

The renderAs attribute is used to open the Visualforce Page in different format like- HTML, pdf, and excel. For example, to show the invoice in PDF format, use renderAs =”pdf”, for HTML, use renderAs =”html”.

For Excel:

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

Locker Service

Locker Service is a powerful security architecture for Lightning components. Locker Service enhances security by isolating Lightning components that belong to one namespace from components in a different namespace. Locker Service also promotes best practices that improve the supportability of your code by only allowing access to supported APIs and eliminating access to non-published framework internals:-At a high level, Lightning Locker uses various technologies and techniques that are intended to do the following:  

Prevent: 

  • Components from causing XSS and similar security issues 
  • Components from reading other component’s rendered data without any restrictions 
  • Components from calling undocumented/private APIs 

dont miss out iconCheck out anther amazing blog by Navdita here: What is a Queue in Salesforce? | All You Need to Know

Enable:

  • Cool new features like client-side API versioning similar to REST API versioning 
  • Faster security review 
  • Better and more secure JS development practices 
  • Running 3rd party JS frameworks like React, Angular and so on 
  • Easily adding or removing new security features and policies 

Responses

Popular Salesforce Blogs