Thursday, September 13, 2018

Action support in salesforce

We use action support to support another visualforce component,the events include "onchange", "onclick" etc.

**************************************************************************************************************

Let's take an example,
Here as the user enter the contact name i.e(Change the name) in input text field highlighted in green colour the action support will trigger and will call the controller method.

Visualforce:

<apex:page controller="createcontact1">

  
  <apex:form id="test">
  
  <apex:inputText value="{!contactname}">
  <apex:actionSupport event="onchange"  action="{!callControllerMethod}" reRender="pageblockid"/>
  </apex:inputText>
  <apex:pageblock id="pageblockid">
 <apex:pageBlockTable value="{!contactList}" var="con">
 <apex:column value="{!con.name}"/>


 </apex:pageBlockTable>
  
  </apex:pageblock>
  
  </apex:form>
</apex:page>


Controller:

public class createcontact1{
public string contactname{get;set;}
public list<contact> contactList{get;set;}
public void callControllerMethod()
{

contactList=[select name from contact limit 1];

}

}

**************************************************************************************************************

No comments:

Post a Comment