+ Start a Discussion

Error: <apex:actionFunction> may not be used within an iterable component.

I am trying to send the input field value to the controller class from VF page and getting error inside the action funciton method :


Here I want to pass three parameters to the controller class :

prodcnt, dealcnt and obj.dsObj.NAS_QC__c ... i am getting the error :


Error: <apex:actionFunction> may not be used within an iterable component. You can use <apex:param> to define parameters for the function and pass iteration-specific values via the parameters.




<apex:variable var="prodcnt" value="{!0}" />  // To the get the row number of the product table
<apex:pageBlockTable value="{!selectedProducts}" var="product" id="dealSplitsPBTable">
<apex:column >
<div class="columnHeaderBox">
{!product.product.ProductCode}&nbsp; - &nbsp; {!product.product.Name}
<apex:variable var="dealcnt" value="{!0}" /> // To get the row number of the deal table
<apex:pageBlockTable value="{!product.dealSplits}" var="obj">

<apex:column headerValue="Delete?">
<apex:inputcheckbox value="{!obj.isSelected}" rendered="{!NOT(obj.isSummaryRecord)}"/>

<apex:column headerValue="QC/DM Name">
<apex:inputField value="{!obj.dsObj.NAS_QC__c}" onchange="ChangeTheManager(this, prodcnt, dealcnt);" rendered="{!NOT(obj.isSummaryRecord) && NOT(obj.isFirstRecord)}"/>
<apex:outputLabel value="" style="text-align:right; font-weight: bold;" rendered="{!obj.isSummaryRecord}"/>
<apex:OutputField value="{!obj.dsObj.NAS_QC__c}" rendered="{!NOT(obj.isSummaryRecord)&& (obj.isFirstRecord)}"/>
<apex:actionFunction name ="setManager" action ="{!selectManager}" rerender = "dealSplitsPBTable">
<apex:param value = "{!obj.dsObj.NAS_QC__c}" assignTo = "{!currentUserId}" />
<apex:param value = "{!prodcnt}" assignTo = "{!currentProdIndex}" />
<apex:param value = "{!dealcnt}" assignTo = "{!currentDealIndex}" />




You are getting this error as you have placed action function inside Page block table: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm

Put the <apex:actionFunction> after the iteration component, and inside the iteration put a normal JavaScript function that calls it.


Thanks for the reply,

If i declare the action function outside the iteration , then how will the three parameters get passed as I am refering to a input text field of table..




Just wondering - you can actually use the ActionSupport tag rather that actionfunction as you are caling the functions inside the crontroller and not javascript.