[SalesForce] Passing dynamic parameters to a function (VisualForce)

I want to pass a dynamic parameter from a Visualforce into a custom apex controller. This parameter is in a table and will have a Contact's id associated with each row on the button that is being pressed to execute my custom function. The problem I'm having right now is that it demands that I pass in an expression.

EDIT:

This is the signature I'm trying to use – public PageReference addMemberToCase(string memberID) And it's going to be executed via a command button. So I'd want the apex code to look like this – <apex:commandButton value="Add to Case" styleClass="btn btn-primary addBtn" id="memberID=SomehowDynamicID?" action="{!addMemeberToCase({!a.contact.id})}"/>

Here's a photo of a row that I'm trying to create TABLE ROW

Best Answer

What you can do is have instance variables in your custom controller and assign your parameters dynamically in your visual force page.

In your controller:

    ID myID {get;set;}

    public void addMemberToCase()
    {
        Id IdOfMember = this.myID;'
        //do your logic here
    }

In your visualforce page:

    <apex:element ......>
       <apex:actionSupport action="{!addMemberToCase()}">
          <apex:param assignTo="{!myID}" value="{!repeaterVar.ID}" />
       </apex:actionSupport>
    <apex:element ......>
Related Topic