+ Start a Discussion
nasir jawednasir jawed 

How to Display Image in VF page using controller



I have created a formula field using CASE and in that i am diaplaying image in a custom object called QUOTA.I can see the Image.But i the customer want to see the image in a VF page.


My formula field is called MonDr and its formula is 


MonDr =IF(Monday_Achievement__c < Monday_Quota__c , "Black",IF(Monday_Achievement__c > Monday_Quota__c,"Red",IF(Monday_Achievement__c == Monday_Quota__c,"Yellow",null)))


and i am displaying this image by using CASE


MonDrImage(text)=IMAGE(CASE( MonDr__c , "Black"," /servlet/servlet.ImageServer?id=015O00000004oBU&oid=00DO00000005GiK&lastMod=1315504942000","Yellow","/servlet/servlet.ImageServer?id=015O00000004oBe&oid=00DO00000005GiK&lastMod=1315504988000","Red","https://c.cs5.content.force.com/servlet/servlet.ImageServer?id=015O00000004oBZ&oid=00DO00000005GiK&lastMod=1315504968000",""),"",30,30)


As i can see the image in page layout when the following condition are meet.


How can i dispay the same image in VF page????


As i had created the VF page and controller for this

<apex:page showHeader="false" controller="DataRepresentation" extensions="DataRepresentation">
    <h1>My Data Representation</h1>
    <apex:pageBlock >
    <apex:pageBlockTable value="{!display}" var="dis">
     <apex:outputLabel >Monday:</apex:outputLabel>  
    <apex:outputText value="{!dis.MonDrImage__c}" escape="false"/>

 The apex class is :

public class DataRepresentation {

  public Quotas__c q{get; set;}
  public String s;
  public Quotas__c getdisplay(){
        Id usrId = UserInfo.getUserId();
        Goals__c g =[Select id from Goals__c where User__c=:usrId];
            q =[select MonDrImage__c,Monday_Quota__c from Quotas__c where 
                Week_of__c =: System.Today().toStartofWeek()
                and RecordTypeId=:Utility.getRecordTypeId('Daily')
                and Quota_For__c='Leads CY'
                and Goal__c=:g.Id limit 1
             //System.debug('image:'+ q.Monday_Quota__c); 
              return q;



:Please help me how can i display that formula field in VF page for Monday Quota






Instead of outputTex use <apex:outputField>. Does it work??