1

I have this below code component where i am displaying custom opportunity field history related list.

<apex:component controller="GenericHistoryComponentController">
<!-- Attribute Definition -->
<apex:attribute name="myObject1" description="Object we wish to view the history of" type="SObject" required="true" assignTo="{!myObject}" />
<apex:attribute name="recordLimit1" description="Number of lines of history to display" type="Integer" required="false" assignTo="{!recordLimit}" />

<!-- Object History Related List -->
<apex:pageBlock title="{!objectLabel} Field History">
    <apex:pageBlockTable value="{!ObjectHistory}" var="History" >
        <apex:column headerValue="Date"  value="{!History.thedate}"/>
        <apex:column headerValue="User">
            <apex:outputLink value="/{!History.userId}"> {!History.who} </apex:outputLink>
        </apex:column>
        <apex:column headerValue="Action"><apex:outputText escape="false" value="{!History.action}"/></apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>
</apex:component>

I want to display No records to display like below if there are no records.

Regardsenter image description here

1 Answer 1

3
<apex:pageBlock title="{!objectLabel} Field History">
    <apex:pageBlockTable value="{!ObjectHistory}" var="History" rendered="{!ObjectHistory.size > 0}">
        <apex:column headerValue="Date"  value="{!History.thedate}"/>
        <apex:column headerValue="User">
            <apex:outputLink value="/{!History.userId}"> {!History.who} </apex:outputLink>
        </apex:column>
        <apex:column headerValue="Action"><apex:outputText escape="false" value="{!History.action}"/></apex:column>
    </apex:pageBlockTable>
<apex:outputpanel  rendered="{!ObjectHistory.size== 0}">
     No records to display.
</apex:outputpanel>
</apex:pageBlock>

Check this updated code. use rendered condition.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .