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

  • and how do you want to pass in? – Ashwani Jun 17 '15 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})}"/> – Andrew Budziszek Jun 17 '15 at 13:20
  • 1
    I don't think you mean static. That sounds quite stateful. – Adrian Larson Jun 17 '15 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. – Andrew Budziszek Jun 17 '15 at 13:52
  • Here's an image of a row from the table I'm creating - Table Row – Andrew Budziszek Jun 17 '15 at 14:00
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 ......>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.