• Mike Day
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi All,

 

Please help to display an attachment in visualforce page...

 

i have the following Apex Class:

 

public class PropUpload  
{  
    public Id recId  
    {    get;set;    }  
      
    public PropUpload(ApexPages.StandardController ctlr)  
    {  
       recId = ctlr.getRecord().Id;       
    }  
      
    public string fileName   
    {    get;set;    }  
      
    public Blob fileBody   
    {    get;set;    }  
    
    public PageReference UploadFile()  
    {  
        PageReference pr;  
        if(fileBody != null && fileName != null)  
        {  
          Attachment myAttachment  = new Attachment();  
          myAttachment.Body = fileBody;  
          myAttachment.Name = fileName;  
          myAttachment.ParentId = recId;  
          insert myAttachment;  
             PageReference page = ApexPages.currentPage();
             page.setRedirect(true);
             return page;              
        }  
        return null; 
    }          
}

 

 

and the following visualforce page:

 

<apex:page standardController="opportunity_proposals__c" extensions="PropUpload">

 <apex:form >

 <apex:pageblock >

    <div class="upload">

    <table><tr>

      <td><apex:inputFile value="{!fileBody}" filename="{!fileName}" styleClass="input-file"/></td> 

      <td><apex:commandButton value="Upload Attachment" action="{!uploadFile}"  styleClass="upload-button"/></td>

    </tr></table>

   </div> 

   </apex:pageblock>

</apex:form>

 

<apex:pageBlock >

   <apex:repeat value="{!opportunity_proposals__c.attachments}" var="​attachment">

      <embed src="/servlet/servlet.FileDownload–file={!attachment.id}" width="100%" height="20px"/>

                </apex:repeat>

</apex:pageBlock>

   

  

 

 </apex:page>

Hi my header name goes away when I render the column but the value comes up???

 

<apex:column rendered="{!dd.TermD='9.2'}">
<apex:facet name="header">Subject Area</apex:facet>
<apex:outputText value="{!dd.Subject}"/>
</apex:column>

 

 Thanks

 

Message Edited by MMA_FORCE on 03-19-2010 11:07 AM