[SalesForce] Pass record ID from apex:repeat to controller variable

How would I go about passing the ID from a record in an apex:repeat iteration into a variable used in a controller method and then display the value the method returns in the VF page?

I've hacked around quite a bit with apex:param but haven't been able to get this to work as expected.

Here's where I'm at so far:

<apex:repeat value="{!mycourses}" var="course">
  <div class="course clearfix">
    <div class="progress-container">
      <apex:input type="text" value="{!wholeNumberComplete}" styleclass="progress">
        <apex:param name="courseId" value="{!course.id}" assignTo="{!courseId}"/>
      </apex:input>
      <label>Complete</label>
    </div>
  </div>
</apex:repeat>

public List<Training_Plan__c> mycourses;
public List<Learning_Assignment__c> learnings;
public Decimal displayNumber {get; set;}

public List<almond__Training_Plan__c> getmycourses() {
  mycourses = SystemUtils.getCourses();
  learnings = SystemUtils.getLearningAssignments(courseId);
  displayNumber = learnings.size();
  return mycourses;
}

Thanks in advance for the assistance.

Best Answer

I'm not sure if you didn't copy all of your code over or not but I do not see a variable named courseId. Also from the developer guide...

The component can only be a child of the following components:

<apex:actionFunction>
<apex:actionSupport>
<apex:commandLink>
<apex:outputLink>
<apex:outputText>
<flow:interview>

There is an awesome blog that will walk you through an example as well here. Example from the blog:

<apex:commandButton value="Del" action="{!delCont}" rerender="all">
   <apex:param name="contIdParam" value="{!cont.id}" assignTo="{!contIdChosen}"/>
</apex:commandButton>

public String contIdChosen {get; set;}

Related Topic