0

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

7
  • and how do you want to pass in?
    – Ashwani
    Commented Jun 17, 2015 at 13:19
  • 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})}"/> Commented Jun 17, 2015 at 13:20
  • 1
    I don't think you mean static. That sounds quite stateful.
    – Adrian Larson
    Commented Jun 17, 2015 at 13:39
  • Maybe static isn't the right word. What I mean is that each button is going to have it's own id based on the contact's Id that is going to be filling that row of a table. Commented Jun 17, 2015 at 13:52
  • Here's an image of a row from the table I'm creating - Table Row Commented Jun 17, 2015 at 14:00

1 Answer 1

2

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 ......>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .