I am trying this below code to view all the attachments in a single window, but i am unable to do it. I am able to view only one attachment at a time.
Is there any solution or workaround where i am view all the attachments in a single window.
Apex Class -
public class AttachmentClass{
public string attachmentid {get; set;}
public List<Attachment> atch {get; set;}
public AttachmentClass(){
atch = new List<Attachment>();
atch = [select Id from Attachment];
For(Attachment a:atch){
attachmentid=a.Id;
}
//attachmentid='00P9000001HdVtc';
}
}
vf page -
<apex:page controller="AttachmentClass">
<a href="{!URLFOR($Action.Attachment.Download, attachmentId)}" class="btn btn-info">
<span class="glyphicon glyphicon-save-file"></span> Download </a>
<br/><br/>
<apex:repeat value="{!atch}" var="a">
<a href="#" class="btn btn-info" onclick="return window.open('{!URLFOR($Action.Attachment.Download, a.Id)}','_top');">
<span class="glyphicon glyphicon-save-file"></span> Preview</a>
</apex:repeat>
</apex:page>