I know there are other questions similar to this but I could not figure out a way to solve my issue. In my Visualforce page, I have a repeater - I need to call the controller method to get data from another object using ID from the repeater object.


  <apex:repeat var="a" value="{!articles}">            
        <!-- this is how I am setting the ArticleId variable in apex ---NOT WORKING -->
        <apex:param name="ArticleId" value="{!(a.Article_Id__c)}" assignTo="{!ArticleId}"/>          

        <!setFaqAnswer>  <!-- Calling the method -->
        <div class="divQuestion" "> {!a.Title__c} </div>
        <div class="divSummary" > {!a.Summary__c} </div>
        <div  class="divAnswer" > {!faq.Answer__c} </div>  <!--   <-- Using the faq object here -->


public FAQ faq {get;private set;}

public Id ArticleId {
    get; set;

public void setFaqAnswer {
    get {
        try {
            faq = [select Answer__c, Links__c from FAQ__kav where KnowledgeArticleId = :ArticleId and IsVisibleInPkb = true];
        catch (QueryException qe) {
            System.debug('@@@@' + qe); // <-- Not being able to view this in setup>log>debug logs
  • You can't use the repeater to retrieve FAQs related to each Article in the way you've got it written. Can you edit your question and add the relevant bit of code which is performing the query for Articles?
    – Mark Pond
    Dec 10, 2014 at 20:14

2 Answers 2


Build your data structure in your controller class using a wrapper (AKA decorator) class such as this:

public class ArticleWrapper {
    public Article Art {get; set;}
    public FAQ__kav Faq {get; set;}

And then make your repeater loop round a list of the ArticelWrapper classes.

You can't use Visualforce repeaters in the same way you use for loops in apex - do the apex bit first, then use the repeater purely for generating the user interface.


I solved my problem using Visualforce Component. I am passing value from the page to this componet.

Here is my component:

<apex:component controller="PKB_DataForScraping_MobileController">
    <apex:attribute name="articleId" description="Article Id" type="Id" assignTo="{!artId}" required="true"/>

I created controller for the component like Force Hero said:

public with sharing class PKB_DataForScraping_MobileController{ 
   public Id artId {
        set {
            artId = value;

   public FAQ__kav getFaq() {
       try {
              faq = [select Answer__c, Links__c from FAQ__kav where PublishStatus = 'Online' and KnowledgeArticleId = :artId and IsVisibleInPkb = true];
       catch (QueryException qe) {}
       return faq;

This is how I call this component from the page:

<c:PKB_SearchResultForScraping_Mobile articleid="{!a.Article_Id__c}" />      

This is equivalent of calling a method with parameters from Salesforce page.

You must log in to answer this question.

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