h:commandlink中的target =“_ blank”未在浏览器的新选项卡中打开页面

问题描述 投票:4回答:2

当h:commandlink与target =“_ blank”一起使用时,我的h:commandLink在同一页面/窗口上打开/预览pdf文档。我希望它在浏览器的新选项卡中打开

哪里可以是错误?

Preview.xhtml代码:

<h:commandLink  id="DocUpoadPreview" action="#{documentController.previewUploadedFile}" value="Preview" target="_blank" >

             </h:commandLink>

在previewuploadedFile()中,操作encription / decryption和其他一些使用pdf的进程是必需的,这就是为什么不使用这就是为什么不在这里使用h:outputlink。在操作过程之后,我想重定向到另一个页面(previewUploadedDoc.xhtml),该页面使用primefaces p:media标签来预览文档。

public String previewUploadedFile() throws Exception {


  //decryption process and adding water mark here//
FacesContext.getCurrentInstance().getExternalContext()
        .redirect("previewUploadedDoc.xhtml");}
jsf-2 primefaces
2个回答
3
投票

试试吧:

<h:commandLink  id="DocUpoadPreview" action="#{documentController.previewUploadedFile}" value="Preview" target="_new" />

-1
投票

target =“_ new”不是target的有效值。它将_new定义为新页面的名称。

这是有效值:qazxsw poi

© www.soinside.com 2019 - 2024. All rights reserved.