0

I have a visualforce page with a search button, and when clicked shows a candidate name in a page block table.

My problem is that before I click the search button, the pageblock table header is displayed without information.

This is my code.

<apex:page standardController="Candidate__c" showheader="false"
        extensions="cansearchcontroller">  
    <apex:form>  
        <apex:inputText value="{!searchstring}" label="Input" />   
        <apex:commandButton value="Search records" action="{!search}"
                rerender="Appear"/>  
        <apex:commandButton value="Clear records" action="{!search}"  />  
        <apex:messages /> 
        <apex:outputPanel id="Appear">
            <apex:pageBlock mode="maindetail" >
                <apex:pageblockTable value="{!can}" var="a">  
                    <apex:column value="{!a.id}"/>
                </apex:pageBlockTable>    
                <apex:pageblockTable value="{!app}" var="b">  
                    <apex:column value="{!b.Status__c}"/>
                    <apex:column value="{!b.Job__c}"/>
                </apex:pageBlockTable>   
            </apex:pageBlock> 
        </apex:outputPanel>
    </apex:form>     
</apex:page>

Can you help me?

Thanks a lot.

1 Answer 1

0

If you are saying that you don't want the table headers to appear before the search is done then you can add rendered to each table so that the table only appears when there are rows:

            <apex:pageblockTable value="{!can}" var="a" rendered="{! can.size > 0}">  
                <apex:column value="{!a.id}"/>
            </apex:pageBlockTable>    
            <apex:pageblockTable value="{!app}" var="b" rendered="{! app.size > 0}">  
                <apex:column value="{!b.Status__c}"/>
                <apex:column value="{!b.Job__c}"/>
            </apex:pageBlockTable> 

But make sure that the can and app lists are initialised to empty lists and not null in your controller.

2
  • Yes, give me this error The value 'null' is not valid for operator '>' How can I change my controller?
    – lisyy
    Commented Oct 10, 2014 at 16:56
  • Include can = new List<Candidate__c>() in your constructor and the equivalent for app.
    – Keith C
    Commented Oct 10, 2014 at 17:31

You must log in to answer this question.

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