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
mac adminmac admin 

how to use the action region in div tag

Hi everyone,
I want to use <apex:actionregion > component in <div></div>tags in mycustom visualforce page. Can anyone help me over.

Regards,
mac
Magesh Mani YadavMagesh Mani Yadav
Hi Mac,

May i know the reason for using <apex:actionregion >. Do you have any element which makes AJAX call in that div?
 
Rupal KumarRupal Kumar
Hi,
In this post i am giving an example of <apex:actionRegion> usage in visualforce. it will use to achieve AJAX functionality to partial page refresh.
Vf 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;
  
    }
  }
 }

 }
Releted Link- http://s18.salesforce.com/01I36000000M9jhEAC?setupid=CustomObjects  (http://s18.salesforce.com/01I36000000M9jhEAC?setupid=CustomObjects)


Thanks 
Rupal Kumar
http://mirketa.com