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

"rendered" attribute in the pageBlockTable is not working

May I ask if you could offer me some quick help on some elementary questions please? I am new to VF. Thanks in advance.



I am very puzzled that the "rendered" attribute in the pageBlockTable is not working out for me.


Note: account.Pot_Dup_Info__r is the relationship key to a list of related objects.


1. When there is no row to be displayed, this block is displayed anyway.



2.  However, when there is indeed row to display and if I change the value of "render" to the following

" rendered="{!(ISNULL(account.Pot_Dup_Info__r))}

this attribute can successfully prevent the block from displaying.


I am not sure what is going on here… Why is it so difficult to do such a small thing…?


I tested out the ISNULL function and it seemed to give me some inconsistent result compared to (xyz !=null). Unfortunately, I don't seem to be able to specify "{!account.pot_dup_info_r != null)" as the value of the "rendered" attribute.


In essense, I just want to show "no row to display" when there is none… unfortunately, that "rendered" attribute does not work for me, and it always shows me the first column header even if there is no data to display.


B. I am uncertain why there is a huge white space underneath my VF section on the Account page… Is there a way to get rid of it?


Also, is there a way to display a VF section in the same way as the other related objects are displayed? e.g. how to display it as a separate section like Open Activities and Active History on the Account page.


Could you please help?


Thanks a lot.


here is the code:

<apex:page showHeader="false" standardController="Account">

<apex:form >

<apex:pageBlock title="Potential Duplicates">

<apex:pageBlockButtons location="top">

<!-- <apex:commandButton value="New Potential Duplicate" onClick="window.parent.location='/a0X/e?CF00NT0000000uIC9={!account.Last_Name__c}%2C+{!account.First_Name__c}+{!account.Middle_Name__c}&CF00NT0000000uIC9_lkid={!}&retURL=%2F{!}';"/> -->

<apex:commandButton value="New Potential Duplicate" onClick="window.parent.location='/apex/Potential_Duplicate?id={!}&retURL=%2F{!}';"/>


<apex:pageBlockSection columns="1">

<apex:pageBlockTable value="{!account.Pot_Dup_Info__r}" var="item" rendered="{!NOT(ISNULL(account.Pot_Dup_Info__r))}">

<apex:column headerValue="Action">

<apex:commandLink value="Merge" onClick="window.parent.location='/apex/NEUMergeAccount?masterAccountId={!}&mergeAccountId={!item.Potential_Duplicate__c}&potentialDuplicateId={!}&retURL=%2F{!}';">



<apex:commandLink value="Delete" onClick="if (confirmDelete()){ window.parent.location='/setup/own/deleteredirect.jsp?delID={!}&retURL=%2F{!}'; }"/>


<apex:column value="{!item.Potential_Duplicate__c}" onClick="top.parent.location='/{!item.Potential_Duplicate__c}';"/>

<apex:column value="{!item.Constituent_Type__c}"/>

<apex:column value="{!item.Home_Street_1__c}"/>

<apex:column value="{!item.createddate}"/>


<apex:pageblockTable id="docTable" value="{!account.Pot_Dup_Info__r}" rendered="{!(ISNULL(account.Pot_Dup_Info__r))}" var="docProperty" columns="1">

No row to display






I believe that the issue is that the collection that contains the objects in a relationship is never going to be null - it may be emoty but that is quite different from being null. One issue is that currently there is no direct way to reference the count or size properties of a collection in a page formula (on the roadmap we have just not had time to get to it yet). The workaround is to expose a property on your controller or extension that returns the count or true if the collection is empty etc.

I need some help on this one please.  I've included a snippet of my code just to point out what's happening.  In the output text I have above my table is always 0 even though I have records in my table that are displayed.  I'm trying to render the pageBlock based on there being rows in the List.  So I was wanting to use rendered="{!products.size>0}"  but I can't get it to work because it always returns 0.  HELP PLEASE!

<apex:outputText value="{!products.size}"/> <!-- Search Results --> <apex:pageBlock title="Search Results"> <apex:pageBlockTable value="{!products}" id="productList" var="p"> <apex:column > <apex:facet name="header"> <apex:outputText value="Dropped"/> </apex:facet> <apex:outputText value="{!p.Dropped__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock>