apex:actionFunction – Salesforce.com

There are times when we have to update components based on events on other parts of visualforce pages.
So below is the code that can be used for reference.
You can use below code for reference here we are updating a checkbox based on
change in account source.
<apex:page extensions=”testComponent” id=”thepage” standardcontroller=”Account”>
<apex:form>
<apex:inputfield value=”{!acc.AccountSource}”>
<apex:actionsupport action=”{!changeCheckBox}” event=”onchange” rerender=”pan” status=”counterStatus”>
</apex:actionsupport></apex:inputfield>
<apex:outputpanel id=”pan”>
<apex:inputfield id=”test” value=”{!acc.check__c}”>
</apex:inputfield></apex:outputpanel>
<apex:actionstatus id=”counterStatus” starttext=” (incrementing…)” stoptext=” (done)”>
</apex:actionstatus></apex:form>
</apex:page>
public with sharing class testComponent {
public testComponent() {
}
public Account acc{get;set;}
public testComponent(ApexPages.StandardController controller) {
acc=[select id,AccountSource,check__c from account where id=’0019000000CJ6QZ’];
}
public pagereference changeCheckBox(){
acc.check__c=true;
return null;
}
}


Source : http://www.saasanalogy.com/apexactionfunction-salesforce-com/

Comments

Popular posts from this blog

Salesforce.com: Expression Operators in Salesforce lightning Components

Custom Calendar on VisualForce Page

Salesforce.com: Scheduled Apex