2012-12-28 66 views
4

當h:commandlink與target =「_ blank」一起使用時,我的h:commandLink正在同一頁面/窗口中打開/預覽PDF文檔。我希望它在瀏覽器的新選項卡中打開target =「_ blank」in h:commandlink在瀏覽器的新選項卡中未打開頁面

哪裏可以出錯?

Preview.xhtml代碼:

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

      </h:commandLink> 

在previewuploadedFile()動作encription /解密和處理PDF其他一些工藝要求是使用必要的原因,這就是爲什麼不使用H:outputLink的位置。在操作過程之後,我想重定向到使用primefaces p:media標籤預覽文檔的另一個頁面(previewUploadedDoc.xhtml)。

public String previewUploadedFile() throws Exception { 


    //decryption process and adding water mark here// 
FacesContext.getCurrentInstance().getExternalContext() 
     .redirect("previewUploadedDoc.xhtml");} 
+3

你嘗試 「_new」,而不是 「_blank」? –

+0

「_new」正在爲我工​​作。 (使用JSF 2和Firefox) – LStrike

+0

我有同樣的問題。我添加了ajax =「false」,它爲我工作。 –

回答

3

試試:

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