You need to sign in to do that
Don't have an account?
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 > <!-- "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>
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 > <!-- "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
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 > <!-- "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>
Thank-you! I wish if I had searched for help sooner :)