1

I'm new in Force.com. Been trying to display my products on pageblocktable. However, the issue here is that, the product image display the same for all column. I have image field in my custom products which has a formula datatype. How do I display my image based on their product ID?

VF CODE:

<apex:pageBlock title="Products">
    <apex:pageBlockTable value="{!productList}" var="item" id="s">
        <apex:column value="{!item.Name}"/>
        <apex:column value="{!item.Price__c}"/> 
        <apex:column value="{!item.Size__c}"/> 
        <apex:column value="{!item.Colour__c}"/> 
        <apex:column >
            <apex:image value="/servlet/servlet.FileDownload?file={!imageURL}" id="someImage" height="200" width="300"/>
        </apex:column>
    </apex:pageblocktable>
</apex:pageblock>

CONTROLLER CODE:

public String imageURL{get;set;}

public list<Product__c> productList{set;get;} 

public Product ( ){
    productList= [Select Name, Price__c, Size__c, Colour__c, Image__c, ImageID__c From Product__c];

    List<document> documentList=[select id from document];
    for (document d : documentList){
        imageURL = d.id;
        productList =  [Select  Name, Price__c, Size__c, Colour__c, Image__c, ImageID__c FROM Product__c WHERE ImageID__c = :imageURL ];
    }   
}

thanks in advance! :)

  • 2
    Where's imageURL coming from and what's the value of ImageID__C on your product records ? If that's the part you need in the serverletUrl it might be as simple as ?file={!item.ImageID__c}" – Samuel De Rycke Oct 24 '14 at 10:07
  • @SamuelDeRycke Thanks Samuel! I created an ImageID__c field to store the image id but oversee that field. It works now! :) – taradyn Oct 24 '14 at 12:29
0

Mistake was pointed out by Samuel. It works now by editing-> ?file={!item.ImageID__c}

| improve this answer | |

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.