【问题标题】:XPages: File Download control link urlXPages:文件下载控制链接 url
【发布时间】:2013-12-18 12:52:17
【问题描述】:
我有一个文件下载控件,它列出了我数据库中某些文档的附件。
我想在每一行旁边显示一个图标,并使其成为该行附件的链接。
如果不确定如何为每一行执行此操作,我们假设我只有 1 行。如何获取附件的链接,以便在链接控件中将其声明为 href?
【问题讨论】:
标签:
file
xpages
lotus-domino
【解决方案1】:
正如我在评论中已经提到的,如果您使用<xp:fileDownload>,您可以添加一个图标,如果您设置displayType="true",并且因为您没有在您的问题中添加代码,我猜您的代码可能看起来像这样:
//..your code
<xp:panel id="row">
<xp:this.data>
<xp:dominoDocument
var="document1"
action="openDocument"
documentId="#{javascript://example... viewEntry.getDocument().getUniversalId()}">
</xp:dominoDocument>
</xp:this.data>
<xp:fileDownload
rows="30"
id="fileDownload1"
displayLastModified="false"
value="#{document1.Body}"
displayType="true">
</xp:fileDownload>
</xp:panel>
//..your code
或者,如果您不使用 <xp:fileDownload> 并且可能只使用带有附件名称的显示行,您可以使用如下内容:
//... your code
<xp:panel id="row">
<xp:repeat
id="repeat1"
rows="30"
value="#{javascript:@AttachmentNames()}"
indexVar="attachmentIndex"
var="attachment">
<xp:link
escape="true"
text="#{javascript:attachment;}"
id="link1"
target="_blank">
<xp:this.value><![CDATA[#{javascript:
var url = facesContext.getExternalContext().getRequest().getContextPath() + "/0/" +
/*in my case: viewEntry.getDocument().getUniversalID()*/
+ "/$File/"+ AttachmentName;
return url;}]]></xp:this.value>
<xp:image id="image1">
<xp:this.url><![CDATA[#{javascript://
var pdfImage = 'pdf.gif';
if(attachment.indexOf("pdf")> 0)
return pdfImage;
}]]></xp:this.url>
</xp:image> 
</xp:link>
<br></br>
</xp:repeat>
</xp:panel>//...your code
行内的<xp:repeat> 将为文档中的每个附件创建一个链接,如果每个文档只有一个附件,则可以将其删除。