首页 > 解决方案 > 将多个 NotesRichText 字段附加到文件下载控件

问题描述

我目前正在为带有 XPages 的旧笔记数据库开发一个小型 Web 前端。

大多数文档是多个 RT 字段中的 DWG 和 PDF 文件,用户应该能够通过 Web 前端下载这些文件。由于文件分布在 10-12 个 RTfields 之间,因此为每个字段设置文件下载控制似乎是一个糟糕的解决方案。所以我尝试通过 SSJS 将多个字段合并为一个,并将其作为文件下载控件的数据源。

<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>

但这只会从第一个字段“VPL_datei”中获取附件,而忽略其他字段中的所有附件。

有没有办法合并字段或提供多个字段作为数据源?我不能编辑 notesdocument 或其表格。

标签: xpages

解决方案


以这种方式无法即时合并 RTItems。您必须先保存项目...

但是您可以创建自己的“FileDownload”-Control。

使用 Domino URL 访问附件

要使用 Domino URL 访问文件附件,您必须知道视图名称、文档名称和文件附件名称。Domino 在保存文件所附加到的文档时会生成文件附件的 URL。这些 URL 以附件的文件名结尾。

句法:

http://Host/DatabaseName/View/DocumentName/ $File/fileattachmentname

其中 View 是视图名称或视图 ID,DocumentName 是文档名称或 ID。$File 是一个特殊标识符,表示文档上的附件。Fileattachmentname 是附件的文件名。

例子:

http://www.acme.com/products.nsf/Documents/ $File/Spec_sheet.pdf


推荐阅读