Well I am working on a visualforce page which has several sections with their own fields. The sections should be independent from each other. Now in one section I've got two operations: add and cancel. When I press the Add button I want that only the fields from its section are processed by the server.
However, when I press the Cancel button I don't need to process the section's field - just cancel. It means when cancelling I don't care if the required fields are populated. For this I am certainly need to cover the Cancel button within the apex:actionRegion element.
Here is a part of my code:
<apex:page>
<apex:form id="recipients">
<!-- other code is skipped for brevity -->
<!-- New recepient section -->
<apex:actionRegion>
<apex:pageBlock id="addNewRecipient"
rendered="{! addNewRecipientVisible }">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Add"
action="{! addRecipient }"
reRender="recipients"/>
<apex:actionRegion>
<apex:commandButton value="Cancel"
action="{! hideAddRecipient }"
immediate="true"
html-formnovalidate="formnovalidate"
reRender="recipients"/>
</apex:actionRegion>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1"
title="New recipient">
<apex:inputField id="recipientLanguage"
value="{! recipient.Language__c }"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:actionRegion>
</apex:form>
</apex:page>
Notice that there are 2 apex:actionRegion elements which are nested. I ran the code and it worked, but I would like to know if putting apex:actionRegion in another apex:actionRegion is a good practice and it does not have any implications.
actionRegion