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
sfdcdev.wordpress.comsfdcdev.wordpress.com 

Display of null values

Hello,

I am trying to disply values in a table. When one of the value is empty, it removes the line below it. Exactly the same problem we would get , when you are coding in HTML and the value returned from the backend is null.

I tried

<apex:outputText value="{!IF(aBilldetail.Proration_Phone__c==null,' &nbsp',aBilldetail.Proration_Phone__c)}"
style="display: block;" />

but this doesnt work becuase SF coverts &nbsp to &amp,nbsp and treats it as a string.

Thanks,
GirishS

Ron HessRon Hess
does "" work?
jwetzlerjwetzler
The way I usually see this handled is with a &nbsp; after the field.


Code:
<apex:outputText value="{!IF(aBilldetail.Proration_Phone__c==null,'',aBilldetail.Proration_Phone__c)}" style="display: block;" />&nbsp;

 

You can also use the ISNULL function instead of checking for null.

Might have some interations with the display:block; you have in there but it should get you started.
dchasmandchasman
and even simpler

Code:
<apex:outputText value="{!nullValue(aBilldetail.Proration_Phone__c,'')}" style="display: block;" />&nbsp;

 

sfdcdev.wordpress.comsfdcdev.wordpress.com
Thanks a lot, I got it working now .. :)

GirishS
SkyWalkerSkyWalker

Hello All

I am trying to display values in a page block table but whenever the value of the column is empty, it removes the line below it.  I have tried to implement the code suggestions above but it does not work.  The visualforce error that I get is Syntax error. Missing ')'. 

Below is a copy of my code.  Any help is appreciated. Thanks

<apex:page standardController="Account">
    <apex:pageBlock title="Hello {!$User.FirstName}!">
        You are viewing the {!account.name} account.
    </apex:pageBlock>
    <apex:detail relatedList="true" />
    <apex:pageBlock title="Account Hierarchy" >
      <apex:PageBlockTable value="{!Account.AccountPartnersTo}" var="cnt" >
      <apex:column headervalue="Account" value="{!cnt.AccountFromId}"/>
      <apex:column value="{!cnt.AccountFrom.Practice_ID__c}" rendered="{!NOT(ISNULL(cnt.AccountFrom.Practice_ID__c))}" />
      <apex:column value="{!cnt.AccountFrom.Facility_ID__c}" rendered="{!NOT(ISNULL(cnt.AccountFrom.Facility_ID__c))}"/>
      <apex:column value="{!nullValue(cnt.AccountFrom.Operational_Status__c,'')}"/>&nbsp;
      <apex:column value="{!cnt.AccountFrom.Operational_Status__c}"/>&nbsp;
      <apex:column value="{!cnt.AccountFrom.Holiday_Coverage__c}"/>     
      <apex:column value="{!cnt.AccountFrom.BillingCity}" />
      <apex:column value="{!cnt.AccountFrom.BillingState}"/>          
    </apex:PageBlockTable>
</apex:pageBlock> 

</apex:page>

dchasmandchasman
Not sure why that is the error displayed (I was able to repro it with just this small example and my team will look into it):

Code:
<apex:page standardController="Account">
<apex:pageBlock title="Account Hierarchy" >
<apex:PageBlockTable value="{!Account.AccountPartnersTo}" var="cnt" >
<apex:column value="{!nullValue(cnt.AccountFrom.Operational_Status__c,'')}"/>
</apex:PageBlockTable>
</apex:pageBlock>
</apex:page>

Regardless the following alternate approach works fine:

Code:
<apex:page standardController="Account">
<apex:pageBlock title="Account Hierarchy" >
<apex:PageBlockTable value="{!Account.AccountPartnersTo}" var="cnt" >
<apex:column>{!nullValue(cnt.AccountFrom.Operational_Status__c,'')}</apex:column>
</apex:PageBlockTable>
</apex:pageBlock>
</apex:page>

 
 

SkyWalkerSkyWalker
Thank you for your reply but I would like to display the header text whether or not it has values or not.  The approach you have suggested removes the header text.  My goal is to not have the lines removed if it is a null value.  Thanks
 

 
dchasmandchasman
I was only focusing on the specific issue (The visualforce error that I get is Syntax error. Missing ')')  with a simplified example - of course you would add in the header value and whatever else you need yourself.


Message Edited by dchasman on 07-02-2008 11:19 AM
sfdcdev.wordpress.comsfdcdev.wordpress.com
I found a solution for you problem. Its simple, just remove the value tag and simply wite as shown in the code bellow :
Code:
                <apex:column >
                <apex:facet name="header"><b>From Date</b></apex:facet>          
                 {!aBill.From_Date__c}
                </apex:column>

 
This worked for me.

Thanks,
Girish Suravajhula.

SkyWalkerSkyWalker
Thank you all for your response but how do you prevent the lines from being removed from the table when it is a null value?
jwetzlerjwetzler
You're talking about divider lines?

{!aBill.From_Date__c}&nbsp;

SkyWalkerSkyWalker

Yes Jill :smileyhappy:

 

Thank you all -- now it works :smileyhappy: