Friday, June 16, 2017

apex:actionFunction with apex:param example.

1. Create an apex class as below example.
/**
 * Controller class for actionFunction with passing parameter example.
 *
 **/
public with sharing class ActionFunctionExmpCtrl
{
 //Variable for input text used in VF.
 public String firstName{get;set;}
 //Variable responsible for holding param value assigned in from VF.
 public String param1{get;set;}

 //action method called from actionFunction.
 public void method1(){
  System.debug('Parameter passed is '+ param1);
 }
}

2. Create a page like below example.

<apex:page controller="ActionFunctionExmpCtrl">
<script>
/**
 * JS method call from onClick operation.
 */
function doJSMethod(fst_name) {
//Varibale to fetch the valuse passed as a parameter on onClick event.
var fstNm = document.getElementById(fst_name).value;
//actionFunction name with parameter.
callMethod1(fstNm);
}
</script>

<apex:form id="formId">
First Name: <apex:inputText id = "f_Nm" value="{!firstName}"/><br/>
<apex:inputCheckbox onclick="doJSMethod('{!$Component.f_Nm}')"/>Click on checkbox to pass First Nmae as parameter

<!-- apex:actionFunction with apex:param -->
<apex:actionFunction action="{!method1}" name="callMethod1" rerender="formId" >
       <apex:param assignTo="{!param1}" name="prmNm" value=""/>
   </apex:actionFunction>

    </apex:form>

</apex:page>

Data Cloud Part 6: Practical (Ingest Physical Store's Customer details and Sales details)

Hope you have already created your Data Cloud Org and also downloaded the Customer's details and Sales details from previous posts.  Now...