+ Start a Discussion
Developer.mikie.Apex.StudentDeveloper.mikie.Apex.Student 

Attachment Pageblocktable not rendering properly

Hey there,

 

I am attempting to create a VF page of the standard attachments, but without the notes. I have managed to create a link which lets me upload attachments to the account. My only problem is that upon attempting to create a pageblocktable in which to view the attachments, it is not rendering properly. I know that it is working, because each time I add an attachment and click save, another row is added it is just blank. The goal is to have the pageblocktable look exactly like the notes and attachments related list....minus all the standard buttons or atleast the 'new note' button. This is my code:

 

<apex:tab label="Attachments"
name="Attachments" id="tabAttachments">
<apex:form >
<apex:pageBlock title="" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save"
action="{!save}"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Attchment"
collapsible="false"
columns="1">
<apex:inputHidden value="{!account.Name}"/>

<apex:outputText value="Attachment: "/><apex:inputFile value="{!attach.body}" filename="{!attach.name}"/><br/>
</apex:pageBlockSection>


<apex:pageBlockTable value="{!Account.attachments}" var="AccAt" cellPadding="4"  border="4" >

<apex:column headerValue="Attachment" />
<apex:column value="{!attach.Name}" />
<apex:column value="{!attach.OwnerId}" />
</apex:pageBlockTable>



</apex:pageBlock>

</apex:form>

 Thank you in advance for your help and for your time.

 

Mikie

Best Answer chosen by Admin (Salesforce Developers) 
georggeorg

in the page block table you are referencing the wrong variable. Use the following code and it will work

 

<apex:pageBlockTable value="{!Account.attachments}" var="AccAt" cellPadding="4"  border="4" >

<apex:column headerValue="Attachment" />
<apex:column value="{!AccAt.Name}" />
<apex:column value="{!AccAt.OwnerId}" />
</apex:pageBlockTable>

All Answers

georggeorg

in the page block table you are referencing the wrong variable. Use the following code and it will work

 

<apex:pageBlockTable value="{!Account.attachments}" var="AccAt" cellPadding="4"  border="4" >

<apex:column headerValue="Attachment" />
<apex:column value="{!AccAt.Name}" />
<apex:column value="{!AccAt.OwnerId}" />
</apex:pageBlockTable>
This was selected as the best answer
Developer.mikie.Apex.StudentDeveloper.mikie.Apex.Student

Perfect, thank you so much. You would not know how to reference the action list would you?