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
santhosh konathala 8santhosh konathala 8 

what action performed by action region in vf page?

Jha dilipJha dilip
<apex:actionRegion> component only defines which components the server processes during a request—it does not define what area(s) of the page are re-rendered when the request completes.
JyothsnaJyothsna (Salesforce Developers) 
Hi Santhosh,

Action Region:
An area of a Visualforce page that demarcates which components should be processed by the Force.com server when an AJAX request is generated. Only the components in the body of the <apex:actionRegion> are processed by the server, thereby increasing the performance of the page.

Using Action region you can bypass the validation rules and increase the visual force page performance.
Please the below example for how to bypass validation rules in visualforce page.

VisualForce Page
<apex:page controller="ActionRegionCLS" >
 <apex:pagemessages id="msgs"></apex:pagemessages>
 <apex:form >
  <apex:pageblock id="pb">
   <table>
     <apex:actionRegion >
      <tr>
        <td> <apex:outputLabel value="Enter Account Number"> </apex:outputLabel> </td>
        <td>
        
         
          <apex:inputtext value="{!reqAccNumber}"/>
          <apex:commandButton value="Retrive" action="{!fillRecord}" rerender="pb,msgs"/>
          </td>
       </tr>  
     </apex:actionRegion>
     <tr>
      <td> <apex:outputLabel value="Account Name"> </apex:outputLabel> </td>
      <td>
        <apex:inputField value="{!accObj.Name}"/>
      </td>
     </tr>
     <tr>
     <td> <apex:outputLabel value="Account Type"> </apex:outputLabel> </td>
      <td>  <apex:inputField value="{!accObj.Type}"/> </td>
     </tr>
   </table>
  </apex:pageblock>
 </apex:form>
</apex:page>


Controller
 
public class ActionRegionCLS{
 public String reqAccNumber{get;set;}
 public Account accObj{get;set;}

 public ActionRegionCLS(){
  accObj = new Account();
 }
 public void fillRecord(){
  if(reqAccNumber !=null && reqAccNumber !=''){
    List<Account> accLst = new List<Account>();
    accLst = [select id,Name,AccountNumber,Type,AnnualRevenue from Account where AccountNumber =:reqAccNumber];
    if(accLst !=null && accLst.size()>0){
     accObj = accLst[0];
    }
    else{
   
     ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Info,' No Records found with this Account Number:'+reqAccNumber);
     ApexPages.addMessage(myMsg);
     accObj  = null;
  
    }
  }
 }

 }

User-added image



Once you enter account number value in Account Number text box and click on Retrieve button, it going to get the details of "Account Name", "Account Type" without reloading the entire page.Using action region we are updating particular HTML area section with Rerender Tag.


 
<apex:commandButton value="Retrive" action="{!fillRecord}" rerender="pb,msgs"/>

Hope this helps you!
Best Regards,
Jyothsna