function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pavan RenjalPavan Renjal 

Check if the list is empty in repeat tag before rendering List

Hi, I need to know how we can check if the list is empty before rendering it. I am not sure if i am doing it right in the below code:

 

<apex:repeat value="{!Contacts}" var="con">
                               
      <apex:commandLink value="{!con.Name}" rendered={!NOT(Contacts.size==0)}"/>
                                     
 </apex:repeat>

  

joshbirkjoshbirk

I would put a OutputPanel around the whole list:

 

<apex:outputPanel rendered={!NOT(Contacts.size==0)}">
<apex:repeat value="{!Contacts}" var="con">
                               
      <apex:commandLink value="{!con.Name}" />
                                     
 </apex:repeat>
</apex:outputPanel>

 

Pavan RenjalPavan Renjal

Thanks for the reply. Somehow its not working for me. Let me check again and come back on this.

joshbirkjoshbirk

tbh, I'm not 100% on that formula.  You might also try putting a getter on an extension or controller like:

 

public Boolean getEmptyContacts() {
     return Contacts.size() == 0;
}

 And have the formula:

rendered="{!NOT(EmptyContacts)}"

 

(or something similar - untested code there)

Pavan RenjalPavan Renjal
Thanks will try :)