I have this VF page below.This is a product page where a list of products are displayed, I was hoping to run it with apex:repeat tag,but the thing is when i try to use var.method in command link and var.prodpic in image tag then i get error that these named methods are not found, there are no methods but the values these contain are the method names. How do I make it work, any idea anyone.any help is appreciated.P.S.- Inventory_c is the custom object where the value for method and product pic is contained.

<apex:page controller="productslistpage" showHeader="false">
  <Apex:form >
        <br/><p style="font-size:19px;font-weight:bold;"> Products available today </p><br/>

       <apex:repeat value="{!Prodlist}" var="prod">

           <apex:CommandLink action="{!invent.ButtonName__c}" >
              <apex:image value="{!URLFOR($Resource[prod.prodpic__c])" width="100" height="180"/><br/>


public Class productslistpage{

    public list<inventory__c> prodlist{get; set;} 
    public string PID{get; set;}
    public string name{get; set;}
    public string usermode{get; set;}

public productslistpage(){

    this.name = ApexPages.currentPage().getParameters().get('Name');
    this.usermode = ApexPages.currentPage().getParameters().get('usermode');
    prodlist = [Select ButtonName__c,Name, Price__c, Stocks__c,productid__c from Inventory__c];

      PageReference pg = new PageReference('/apex/testprodpage');
public pagereference prod1button(){

      PID = '10004';    

      pg.getParameters().put('PID', PID);
      return pg; 

  • Try not using the var keyword, instead use some different word in var="var" as var = "some_other_string" Aug 11 '17 at 10:57
  • yup, usually it is not like that, i just wanted something for the question post, thanks for the info.
    – Niknit
    Aug 11 '17 at 11:00
  • Is your question solved now? Aug 11 '17 at 11:05
  • Nope,in the code it is Invent, it didn't work, same error
    – Niknit
    Aug 11 '17 at 11:13
  • does the repeat value has a collection or object name? I right now have stated object name, is that wrong, should i just be using the list variable that i am using in the controller?
    – Niknit
    Aug 11 '17 at 11:15

The apex:commandLink documentation explains that the action attribute must reference a controller method not an SObject data field. See e.g. Passing Parameters with a CommandLink for how to arrange that and still pass a value.

On the image reference, if prodpic__c holds the name of a static resource this dynamic reference to a static resource pattern is the sort of code you need:

<apex:image value="{!URLFOR($Resource[var.prodpic__c])"/>
  • thanks Keith, umm i have updated the post, Can you please check. the image still doesn't work.
    – Niknit
    Aug 11 '17 at 11:38
  • @Niknit Best you look at the "dynamic reference..." post I linked to for more information.
    – Keith C
    Aug 11 '17 at 11:48

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.