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
Reshmi SmijuReshmi Smiju 

Issue with apex:OutputText

Hi,

Pls let me know, the error with the following code. In the VF page , the headers are not displaying.

<apex:page controller="BulkDeleteSobject2_Controller" showHeader="true" sidebar="true">
    <apex:sectionHeader title="BulkDelete" subtitle="SObject"/>
    <apex:form >
        <apex:pageBlock id="theBlock">
            <apex:pageBlockButtons location="both">
                <apex:commandButton value="Delete Selected" action="{!DeleteSelected}" onclick="if(!confirm('Are you sure?')) return false;"/>
            </apex:pageBlockButtons>
        <apex:pageMessages />
            <apex:pageBlockSection columns="1">    
                <apex:selectList size="1" value="{!SelectedObject}" id="objects">
                    <apex:selectOptions value="{!sObjectList}" />
                    <apex:actionSupport event="onchange" action="{!executeSelect}" reRender="theBlock"/>
                    </apex:selectList>
                    <apex:pageBlockTable value="{!WrapperList}" var="item" id="records">
                        <apex:column style="width:100px;">
                            <apex:facet name="Header">
                                <apex:outputText value="Delete"/>
                            </apex:facet>
                            <apex:inputCheckbox value="{!item.DeleteThis}"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="Header">
                                <apex:outputText value="Name/Id"/>
                            </apex:facet>
                            <apex:outputText value="{!item.Name}" rendered="{!HasName == true}"/>
                            <apex:outputText value="{!item.sObj.Id}" rendered="{!HasName == false}"/>
                        </apex:column>
                    </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Best Answer chosen by Reshmi Smiju
Shikha AgashiShikha Agashi
Please try following:
<apex:page controller="BulkDeleteSobject2_Controller" showHeader="true" sidebar="true">
    <apex:sectionHeader title="BulkDelete" subtitle="SObject"/>
    <apex:form >
        <apex:pageBlock id="theBlock">
            <apex:pageBlockButtons location="both">
                <apex:commandButton value="Delete Selected" action="{!DeleteSelected}" onclick="if(!confirm('Are you sure?')) return false;"/>
            </apex:pageBlockButtons>
        <apex:pageMessages />
            <apex:pageBlockSection columns="1">    
                <apex:selectList size="1" value="{!SelectedObject}" id="objects">
                    <apex:selectOptions value="{!sObjectList}" />
                    <apex:actionSupport event="onchange" action="{!executeSelect}" reRender="theBlock"/>
                    </apex:selectList>
                    <apex:pageBlockTable value="{!WrapperList}" var="item" id="records">
                        <apex:column style="width:100px;" headerValue="Delete">
                             <apex:inputCheckbox value="{!item.DeleteThis}"/>
                        </apex:column>
                        <apex:column headerValue="Name/Id">
                            <apex:outputText value="{!item.Name}" rendered="{!HasName == true}"/>
                            <apex:outputText value="{!item.sObj.Id}" rendered="{!HasName == false}"/>
                        </apex:column>
                    </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

All Answers

Shikha AgashiShikha Agashi
Please try following:
<apex:page controller="BulkDeleteSobject2_Controller" showHeader="true" sidebar="true">
    <apex:sectionHeader title="BulkDelete" subtitle="SObject"/>
    <apex:form >
        <apex:pageBlock id="theBlock">
            <apex:pageBlockButtons location="both">
                <apex:commandButton value="Delete Selected" action="{!DeleteSelected}" onclick="if(!confirm('Are you sure?')) return false;"/>
            </apex:pageBlockButtons>
        <apex:pageMessages />
            <apex:pageBlockSection columns="1">    
                <apex:selectList size="1" value="{!SelectedObject}" id="objects">
                    <apex:selectOptions value="{!sObjectList}" />
                    <apex:actionSupport event="onchange" action="{!executeSelect}" reRender="theBlock"/>
                    </apex:selectList>
                    <apex:pageBlockTable value="{!WrapperList}" var="item" id="records">
                        <apex:column style="width:100px;" headerValue="Delete">
                             <apex:inputCheckbox value="{!item.DeleteThis}"/>
                        </apex:column>
                        <apex:column headerValue="Name/Id">
                            <apex:outputText value="{!item.Name}" rendered="{!HasName == true}"/>
                            <apex:outputText value="{!item.sObj.Id}" rendered="{!HasName == false}"/>
                        </apex:column>
                    </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
This was selected as the best answer
Reshmi SmijuReshmi Smiju
Hi Shikha,

Thanks for the Quick response.
It would be great, if you pls let me know the reason why the facet tag was not working.
Thank you
 
Amit Chaudhary 8Amit Chaudhary 8
apex:facet

A placeholder for content that's rendered in a specific part of the parent component, such as the header or footer of an <apex:dataTable>.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_facet.htm

Best Practices for Using Component Facets
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_additional_facet.htm

In <apex:pageBlockTable it better to user <apex:column headerValue='value'.
or use <apex:outputField not <apex:outputText if you are using the standard field
 
Reshmi SmijuReshmi Smiju
Thank you Amit for the explanation