1

Within an apex:repeat interation, I want to display a checkbox and run a method from my controller when the checkbox is clicked. The method runs an update statement that will update the current record.

I'm using apex:actionSupport to call the method and am attempting to use apex:param to pass the record Id to the controller. However, the Id is not getting passed to the controller. I've read a lot about apex:param and similar issues but haven't been able crack this as of yet. Any ideas on how my VF page or controller needs to be updated?

<apex:repeat value="{!lectureLearnings}" var="learning">
    <apex:outputPanel id='completionStatus'>
      <apex:inputCheckbox value="{!completedStatus}">
        <apex:actionSupport event="onchange" action="{!completeLecture}" reRender="completionStatus"/>
          <apex:param name="completedLearning" value="{!learning.id}" assignTo="{!completedLearning}"/>
      </apex:inputCheckbox>
    </apex:outputPanel>
</apex:repeat>

public String completedLearning {get;set;}
public PageReference completeLecture(){
    system.debug('completedLearning = ' + completedLearning); //returns null in log file
    update completedLearning;
    return null;
}

1 Answer 1

3

Try making your <apex:param> a child of your <apex:actionsupport> element.

<apex:actionSupport event="onchange" action="{!completeLecture}" reRender="completionStatus">
  <apex:param name="completedLearning" value="{!learning.id}" assignTo="{!completedLearning}"/>
</apex:actionSupport>
1
  • That's it, easy to miss! Glad you got it working.
    – Rob
    Sep 21, 2015 at 15:52

You must log in to answer this question.

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