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
sunny@99-chgsunny@99-chg 

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={!l.id}" 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/>
                                                          
                                                              
                                                        </apex:repeat>
                                                         <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="{!l.id}"/>-->
                                                                          </apex:commandLink>
                                                                    <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="{!i.id}"/>
                                                                    </apex:commandLink>
                                                                    
                                                                    <br/><br/>
                                                                 <apex:inputHidden rendered="{!IF(i.Qty__c == 0 ,true,false)}"> <font color='red' >  Out Of Stock  </font></apex:inputHidden>
                                                                
                                                                     <br></br>
                                                                    <apex:outputField value="{!i.Name}"/> <br/>
                                                                    PRICE: <apex:outputField value="{!i.o2bc__Sell_Price__c }"/>     
                                                                </p>
                                                    </div>
                                                </apex:repeat>
                                            </apex:panelGrid>                                 
                                                                               
                                        </apex:pageblocksection>

 

My controller

 

public ApexPages.

StandardSetController con {
     get{
            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, attachment.id 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 ]));
                con.setPageSize(18);
            }
            return con;
        }
        set;
    }



 public List<o2bc__Item__c> getitemlist()
    {
       itemlist = new List<o2bc__Item__c>();
       for(o2bc__Item__c oItem :(List<o2bc__Item__c>)con.getRecords())
        {
       
            system.debug('----ram---'+oItem.Attachments);
                   itemlist.add(oItem);  
          
       
        }
        return itemlist;
    }
 
Please do the needful,it is very urgent..