function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Problem with Attachment

Hai ,


  In my page my client want to show an imge if the Image attachment is not there under a record.




My Page is


 <apex:pageblocksection title="Nexus Upgrade Phone Selection" columns="1"  collapsible="false"   id="pho" >
                                            <apex:panelGrid captionClass="phoneDetails">
                                                <apex:repeat value="{!itemlist}" var="i" >
                                                    <div class="phoneBox">
                                                        <apex:repeat value="{!i.attachments}" var="l">
                                                            <apex:image url="/servlet/servlet.FileDownload?file={!}" styleClass="phoneImage" rendered="{!if( l=='',false,true)}" />
                                                          <!--  <apex:image url="{!$Resource.Freephone}"   styleClass="phoneImage"  rendered="{!if(l=='',true,false)}"> </apex:image> ---> // Here I need the fake image if image attachment is not there

<br/> <br/>
                                                         <p class="phoneDescription"> <!-- this may need reorganizing ?? -->
                                                                    <apex:commandLink value="Detail" action="{!ShowDetail}" styleClass="btn" style="padding:2px 5px 2px 5px; text-decoration:none; color:green;"  >      
                                                                         <!-- <apex:param name="PhID" value="{!}"/>-->
                                                                    <apex:commandLink value="Select" action="{!onphoneselect}" styleClass="btn" style="padding:2px 5px 2px 5px; text-decoration:none; color:green;"  >
                                                                        <apex:param assignTo="{!imageid}" name="PhID" value="{!}"/>
                                                                 <apex:inputHidden rendered="{!IF(i.Qty__c == 0 ,true,false)}"> <font color='red' >  Out Of Stock  </font></apex:inputHidden>
                                                                    <apex:outputField value="{!i.Name}"/> <br/>
                                                                    PRICE: <apex:outputField value="{!i.o2bc__Sell_Price__c }"/>     


My controller


public ApexPages.

StandardSetController con {
            if(con == null) {
                con = new ApexPages.StandardSetController(Database.getQueryLocator([select id,o2bc__Sell_Price__c,o2bc__Item_Code__c,name,Qty__c,(SELECT ContentType,parentid, FROM o2bc__Item__c.attachments WHERE ContentType LIKE '%image%') from o2bc__Item__c where o2bc__Type__c IN ('Freephones','Phones') and o2bc__Sell_Price__c!=0 order by o2bc__Sell_Price__c ]));
            return con;

 public List<o2bc__Item__c> getitemlist()
       itemlist = new List<o2bc__Item__c>();
       for(o2bc__Item__c oItem :(List<o2bc__Item__c>)con.getRecords())
        return itemlist;
Please do the needful,it is very urgent..