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
SarisfdcSarisfdc 

How to pass parameter from apex repeat component to controller

How to pass parameter from apex repeat component to controller through action function.
sandeep sankhlasandeep sankhla
You can make use of Apex:param .
 
<apex:outputLink value="javascript:if (window.confirm('Are you sure?')) DeleteQuoteLineItem('TEST VALUE');">
    Del
</apex:outputLink>

    <apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="showstate">
 <apex:param name="firstParam" assignTo="{!state}" value="" />
 </apex:actionFunction>

Like that you can pass the parameters.

Please check and let me know if that helps you.

Thanks,
Sandeep
Harpreet On CloudHarpreet On Cloud
Take a look at the documentation too for apex:param and apex:actionFunction

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_param.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionFunction.htm

 
<apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="showstate">
        <apex:param name="firstParam" assignTo="{!state}" value="" />
    </apex:actionFunction>


 
SarisfdcSarisfdc
Can you tell me how i should define the paameters stored in apex:param in the controller, so that I can use it
DeepthiDeepthi (Salesforce Developers) 
Hi Sarisfdc,

Please check the below code snippet on using apex:param to pass values from Visualforce to Controller.
 
<apex:page controller="ControllerClass">
<apex:form >
<apex:pageBlock >
    <apex:pageBlockTable var="c" value="{!Cnd}">
        <apex:column headerValue="Name">
            <apex:outputText >
            <apex:commandLink value="{!c.First_Name__c}" action="{!directVal}" reRender="display">
            <apex:param value="{!c.id}" name="getId"/>
            </apex:commandLink>
            </apex:outputText>
        </apex:column>
    </apex:pageBlockTable>

<apex:pageBlockTable var="c1" value="{!Cnd1}" id="display">
    <apex:column headerValue="First Name">
        <apex:inputField value="{!c1.First_Name__c}"/>
    </apex:column>
    <apex:column headerValue="Last Name">
        <apex:inputField value="{!c1.Last_Name__c}"/>
    </apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
 
public class ControllerClass {

    public List<Candidate__c> Cnd {get; set;}
    public List<Candidate__c> Cnd1 {get; set;}
    
    public ControllerClass(){

        Cnd = new List<Candidate__c>();
        Cnd = [select First_Name__c from Candidate__c];
        
    }
  
     public PageReference directVal() {
        Cnd1 = new List<Candidate__c>();
        String str = ApexPages.currentpage().getparameters().get('getId');  //retrieved the record of the selected value and stored as a string
        Cnd1=[select First_Name__c,Last_Name__c from Candidate__c where id=:str];
        return null;
     }
  
  
       
}

Hope this helps you!
Best Regards,
Deepthi