For clarity and maintenance reasons, I'd like to abstract away a commonly-used pageBlockSectionItem pattern in my VF pages to a component like this:
<apex:component >
<apex:attribute name="controllerField" required="true" type="Date" description="Name of controller-referenced Opportunity sobject field"/>
<apex:attribute name="label" required="true" type="String" description="Label to use"/>
<apex:attribute name="oppoId" required="true" type="String" />
<apex:pageBlockSectionItem rendered="{!NOT(ISBLANK(controllerField))}">
<apex:outputText value="{!label}"/>
<apex:outputField value="{!controllerField}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{!ISBLANK(controllerField)}">
<apex:outputText value="{!label}"/>
<apex:outputLink value="{!URLFOR($Page.Oppo_Upload_Document,$ObjectType.Opportunity,[id=oppoId])}" style="color: rgb(23,151,192)">
Upload
</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:component>
and reference multiple times in VF pages like this:
<apex:pageBlockSection>
<apex:outputField value="{!ow.o.blah}"/>
<c:myComponent name="{!ow.o.foodate}" label="The foo date" oppoId="{!ow.o.id}"/>
<apex:outputField value="{!ow.o.ugh}"/>
<c:myComponent name="{!ow.o.bardate}" label="The bar date" oppoId="{!ow.o.id}"/>
<!-- etc etc -->
</apex:pageBlockSection>
But you can't define a pageBlockSectionItem as the top level apex component in a custom component. You get:
Save error: <apex:pageBlockSectionItem> tag must be between <apex:pageBlockSection>
How does one get around this? I don't want the component to be a pageBlock or pageBlockSection. Simulating a pageBlockSectionItem as HTML defeats the ease of maintenance.