Most of the users have no clear idea about the usage of <apex:actionRegion> visualforce tag.In this post I will give a brief idea
<apex:actionRegion> :
An area of a visualforce page that demarcates which components should be processed by the force.com server when an Ajax request is generated .
The <apex:actionRegion> component specifies the components to be processed on force.com server.If no <apex:actionregion> is defined the whole view functions as a region .
Here component means ,all visualforce tags like InputField,InputText,outputPanels etc.
Component processing includes
Conversion: converting from user inputted strings to date,numbers etc.
Validation :running validations like checking required fields.
model update :updating apex bindings i.e controller variables binded to visualforce page merge fields.
Note: Even when using <apex:region/>, the whole form is submitted but only part taken into region will be processed.
The example below will give an idea.
The following is the controller logic
public class regioncontroller {
public String text1{ get; set; }
public String text2{ get; set; }
}
The following is the visualforce page code.
<apex:page controller="regioncontroller ">
<apex:form >
<apex:pageMessages id="messages1"/>
<apex:pageBlock>
<apex:pageBlockSection columns="2" >
<apex:outputText value="name" />
<apex:inputText value="{!text1}">
<apex:actionSupport event="onkeyup" reRender="outname,messages1" />
</apex:inputText>
<apex:outputText value="Job" />
<apex:inputText required="true" id="job2" value="{!text2}" />
</apex:pageBlockSection>
<apex:outputText id="outname" style="font-weight:bold" value="Typed Name: {!text1}" />
</apex:pageBlock>
</apex:form>
</apex:page>
Now if u run the page and type something in the name textfield, u will get validation error because the entire form is submitted and everything in it goes for processing in server and since another inputtext field is made required,we are getting validation error as below
Now modify the visualforce page code as below
<apex:page controller="regioncontroller ">
<apex:form >
<apex:pageMessages id="messages1"/>
<apex:pageBlock>
<apex:pageBlockSection columns="2" >
<apex:actionRegion >
<apex:outputText value="name" />
<apex:inputText value="{!text1}">
<apex:actionSupport event="onkeyup" reRender="outname,messages1" />
</apex:inputText>
</apex:actionRegion >
<apex:outputText value="Job" />
<apex:inputText required="true" id="job2" value="{!text2}" />
</apex:pageBlockSection>
<apex:outputText id="outname" style="font-weight:bold" value="Typed Name: {!text1}" />
</apex:pageBlock>
</apex:form>
</apex:page>
Now when we run the page and type something in name text field,we will not get any validation errors because even though entire form is submitted,only the content present in <apex:actionRegion> will be sent for processing in server and since no required field present in <apex:actionRegion> ,we donot get validation errors.The required field is present outside the <apex:actionRegion> .
<apex:actionRegion> :
An area of a visualforce page that demarcates which components should be processed by the force.com server when an Ajax request is generated .
The <apex:actionRegion> component specifies the components to be processed on force.com server.If no <apex:actionregion> is defined the whole view functions as a region .
Here component means ,all visualforce tags like InputField,InputText,outputPanels etc.
Component processing includes
Conversion: converting from user inputted strings to date,numbers etc.
Validation :running validations like checking required fields.
model update :updating apex bindings i.e controller variables binded to visualforce page merge fields.
Note: Even when using <apex:region/>, the whole form is submitted but only part taken into region will be processed.
The example below will give an idea.
The following is the controller logic
public class regioncontroller {
public String text1{ get; set; }
public String text2{ get; set; }
}
The following is the visualforce page code.
<apex:page controller="regioncontroller ">
<apex:form >
<apex:pageMessages id="messages1"/>
<apex:pageBlock>
<apex:pageBlockSection columns="2" >
<apex:outputText value="name" />
<apex:inputText value="{!text1}">
<apex:actionSupport event="onkeyup" reRender="outname,messages1" />
</apex:inputText>
<apex:outputText value="Job" />
<apex:inputText required="true" id="job2" value="{!text2}" />
</apex:pageBlockSection>
<apex:outputText id="outname" style="font-weight:bold" value="Typed Name: {!text1}" />
</apex:pageBlock>
</apex:form>
</apex:page>
Now if u run the page and type something in the name textfield, u will get validation error because the entire form is submitted and everything in it goes for processing in server and since another inputtext field is made required,we are getting validation error as below
<apex:page controller="regioncontroller ">
<apex:form >
<apex:pageMessages id="messages1"/>
<apex:pageBlock>
<apex:pageBlockSection columns="2" >
<apex:actionRegion >
<apex:outputText value="name" />
<apex:inputText value="{!text1}">
<apex:actionSupport event="onkeyup" reRender="outname,messages1" />
</apex:inputText>
</apex:actionRegion >
<apex:outputText value="Job" />
<apex:inputText required="true" id="job2" value="{!text2}" />
</apex:pageBlockSection>
<apex:outputText id="outname" style="font-weight:bold" value="Typed Name: {!text1}" />
</apex:pageBlock>
</apex:form>
</apex:page>
Now when we run the page and type something in name text field,we will not get any validation errors because even though entire form is submitted,only the content present in <apex:actionRegion> will be sent for processing in server and since no required field present in <apex:actionRegion> ,we donot get validation errors.The required field is present outside the <apex:actionRegion> .