[SalesForce] Display images in pageblocktable column

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! 🙂

Best Answer

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

Related Topic