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
ShikibuShikibu 

Determine array length in VF markup?

I have several pages that contain repeating components (like dataTable) for arrays, which should not be rendered if the array size is zero. Is there a way to accomplish this in VF markup, without having to create a new public property in apex that exposes the size of the array?

 

 

<apex:pageBlockSection title="Assets" rendered="{!renderAssetsForContact}"><apex:dataTable value="{!assetsForContact}" var="asset">

 

public Boolean renderAssetsForContact { get { return assetsForContact.size() > 1; }}

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
ThomasTTThomasTT

{!assetsForContact.size}

 

I wish we could get the array index from markups.... but at least, we can get the size. It helped me a lot. - ThomasTT