Conditional rendered with list size Salesforce Visualforce Page

Conditional rendered with list size Salesforce Visualforce Page

size method can be used in the rendered attribute for conditional rendering based on list size in the Salesforce Visualforce page.

Sample Code:

<apex:pageBlockTable 
     value="{!empList}" 
     var="emp" 
     rendered="{! IF(empList.size > 0, true, false)}">
     <apex:column value="{!emp.Name}"/>
     <apex:column value="{!emp.Age}"/>
</apex:pageBlockTable>

The pageblock will be rendered only if the empList list size from the apex controller is greater than zero.

Leave a Reply