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
dwwrightdwwright 

Formatting Lost in <apex:actionRegion>

I have a problem where I lose standard formatting on a field inside an <apex:actionRegion>. This field has an <apex:actionSupport> component nested inside of it. If I put the actionRegion tags around the entire pageBlock, the formatting stays, but if I put it directly around the field controlling the rerendering, it loses its label and gets aligned all the way to the left. I've tried encasing the whole thing in a pageBlockSectionItem, to no avail. Does anybody know a way around this?

 

 

<apex:pageBlockSection title="Breaker Selection" collapsible="false"> <apex:actionRegion >&nbsp; <!-- "Select the Appropriate Breaker" (Picklist) /--> <apex:inputField value="{!Quality_Document__c.Breaker__c}" required="true"> <!-- When the above value changes, the entire page block is rerendered /--> <apex:actionSupport event="onchange" rerender="thePageBlock" /> </apex:inputField> </apex:actionRegion>

  ..........More Fields........

</apex:pageBlockSection>

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
jwetzlerjwetzler

This is just the way pageBlockSection works.  It will only generate a label and do all of the formatting for you if you give it one direct child component, and that child component is inputField or outputField.

 

If you need any more control over it (to add things like actionRegion) you'll need to use pageBlockSectionItem -- as you guessed -- which is still capable of formatting properly but requires just a little more code.  You'll need something like this:

 

<apex:pageBlockSection title="Breaker Selection" collapsible="false">

<apex:pageBlockSectionItem>

<apex:outputLabel value="{!$ObjectType.Quality_Document__c.fields.Breaker__c.label}" for="breakerField"/>

<apex:actionRegion >&nbsp; <!-- "Select the Appropriate Breaker" (Picklist) /-->

<apex:inputField value="{!Quality_Document__c.Breaker__c}" required="true" id="breakerField"> <!-- When the above value changes, the entire page block is rerendered /-->

<apex:actionSupport event="onchange" rerender="thePageBlock" />

</apex:inputField>

</apex:actionRegion>

</apex:pageBlockSectionItem> ..........More Fields........ </apex:pageBlockSection>

 

 

 

All Answers

jwetzlerjwetzler

This is just the way pageBlockSection works.  It will only generate a label and do all of the formatting for you if you give it one direct child component, and that child component is inputField or outputField.

 

If you need any more control over it (to add things like actionRegion) you'll need to use pageBlockSectionItem -- as you guessed -- which is still capable of formatting properly but requires just a little more code.  You'll need something like this:

 

<apex:pageBlockSection title="Breaker Selection" collapsible="false">

<apex:pageBlockSectionItem>

<apex:outputLabel value="{!$ObjectType.Quality_Document__c.fields.Breaker__c.label}" for="breakerField"/>

<apex:actionRegion >&nbsp; <!-- "Select the Appropriate Breaker" (Picklist) /-->

<apex:inputField value="{!Quality_Document__c.Breaker__c}" required="true" id="breakerField"> <!-- When the above value changes, the entire page block is rerendered /-->

<apex:actionSupport event="onchange" rerender="thePageBlock" />

</apex:inputField>

</apex:actionRegion>

</apex:pageBlockSectionItem> ..........More Fields........ </apex:pageBlockSection>

 

 

 

This was selected as the best answer
dwwrightdwwright
Works beautifully! Many thanks
saadis01saadis01

Thank-you! I wish if I had searched for help sooner :)