I'm currently developing a small web-frontend for a old notesdatabase with XPages.
In most of the documents are DWG- and PDF-Files in multiple RTfields, which the user should be able to download via the web-frontend. Since the files are spread between 10-12 RTfields, having a filedownload-control for every field seems to be a bad solution. So i tried merging multiple fields into one via SSJS and provided this as the datasource for the filedownload-control.
<xp:fileDownload
rows="30"
id="fileDownload2"
displayLastModified="false"
displaySize="true"
displayType="false"
displayCreated="false">
<xp:this.value>
<![CDATA[#{javascript:
var allfiles:lotus.domino.RichTextItem=plan.getDocument().getFirstItem("VPL_datei");
allfiles.appendRTItem(plan.getDocument().getFirstItem("VPL_datei_1"));
allfiles.appendRTItem(plan.getDocument().getFirstItem("PGL_datei"));
allfiles.appendRTItem(plan.getDocument().getFirstItem("Plandatei"));
var file1:com.ibm.xsp.model.domino.wrapped.DominoRichTextItem = new com.ibm.xsp.model.domino.wrapped.DominoRichTextItem(plan, allfiles);
return file1;
}]]>
</xp:this.value>
</xp:fileDownload>
But this only gets the attachments from the first field "VPL_datei" and igonores all attachments in the other fields.
Is there any way to merge the fields or provide multiple fields as the datasource? I must not edit the notesdocument or its form.
Merging RTItems on the fly is not possible this way. You have to save the item first...
But you can create your own "FileDownload"-Control.
Using Domino URLs to access attachments
To access a file attachment using a Domino URL, you must know the view name, the document name, and the file attachment name. Domino generates an URL for file attachments when it saves the documents to which the files are attached. These URLs end with the file name of the attachment.
Syntax:
http://Host/DatabaseName/View/DocumentName/$File/fileattachmentname
Where View is either the view name or the view ID, and DocumentName is the document name or ID. $File is a special identifier that indicates an attachment on a document. Fileattachmentname is the file name of the attachment.
Examples:
http://www.acme.com/products.nsf/Documents/$File/Spec_sheet.pdf