+ Start a Discussion
chris_centrachris_centra 

no label when inputField is in an actionRegion?

easy one, i think, but i can't find it in the forums.  i have a vf page that displays some checkboxes and fields - all are fields on the underlying object.  i added some functionality where i put a checkbox in an actionRegion - so when the checkbox is toggled, stuff happens.  everything works perfectly, but my field label is no longer displayed.  i added it manually, but the style and spacing are lost.  what am i doing wrong?

 

i saw one forum post to put the info in pageblocksectionitems, which i did, but it didn't help.  code snippet is below...

 

Thanks for your help.

chris

 

<apex:actionRegion >
  <apex:pageBlockSectionItem >
    <apex:outputLabel value="{!$ObjectType.SFDC_520_Quote__c.fields.Estimated_SalesTax_Override_Flag__c.label}"
                                        for="SalesTaxOverrideCheckboxField"/>
                       
    <apex:inputField value="{!SFDC_520_Quote__c.Estimated_SalesTax_Override_Flag__c}"
                            rendered="{!SFDC_520_Quote__c.Opportunity__r.Site_Address_State__c == 'NY'}"
                            id="SalesTaxOverrideCheckboxField">   
      <apex:actionSupport event="onchange"
                                        rerender="orderWorksheetDetailPanel" />
   </apex:inputField>

  </apex:pageBlockSectionItem>
</apex:actionRegion>
 

Best Answer chosen by Admin (Salesforce Developers) 
Rajesh ShahRajesh Shah

I had a similar issue. You would need to change the order of the tags. See the example below:

 

<apex:pageBlockSectionItem id="AmountSectionItem"> <apex:outputLabel value="Amount" for="Amount"/> <apex:actionRegion > <apex:inputField required="true" id="Amount" value="{!Account.Amount__c}"> <apex:actionSupport action="{!UpdateTotalAmount}" event="onchange" rerender="Section1" /> </apex:inputField> </apex:actionRegion> </apex:pageBlockSectionItem>

 Action Region will wrap only the input Field and not the complete pageBlockSectionItem. Doing this way, the style is not lost. 

 

 

All Answers

Rajesh ShahRajesh Shah

I had a similar issue. You would need to change the order of the tags. See the example below:

 

<apex:pageBlockSectionItem id="AmountSectionItem"> <apex:outputLabel value="Amount" for="Amount"/> <apex:actionRegion > <apex:inputField required="true" id="Amount" value="{!Account.Amount__c}"> <apex:actionSupport action="{!UpdateTotalAmount}" event="onchange" rerender="Section1" /> </apex:inputField> </apex:actionRegion> </apex:pageBlockSectionItem>

 Action Region will wrap only the input Field and not the complete pageBlockSectionItem. Doing this way, the style is not lost. 

 

 

This was selected as the best answer
sfdcfoxsfdcfox

1) Don't use outputLabel inside actionRegion, unless the label's value comes from a value that is contained in an inputField inside that actionRegion-- since only partial state information is sent when you generate an event inside the actionRegion, labels are not loaded.

 

2) For formatting, place pageBlockSectionItem tags inside a pageBlockSection, which in turn should be in a pageBlock. This will provide the correct formatting.

 

The following would have the same effect:

 

<apex:form id="form1"> <apex:pageBlock> <apex:pageBlockSection> <apex:pageBlockSectionItem rendered="..."> <apex:outputLabel .../> <apex:inputField ...> <apex:actionSupport ... reRender="form1"/> </apex:inputField> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form>