JSF中的target="_blank"与PrimeFaces命令按钮不起作用

4

尝试打开一个新的选项卡以接收来自bean生成的pdf文件。

使用h:commandbutton可以正常工作,但是使用p.commandbutton无法打开选项卡。

尝试在p:commandbutton上使用onclick和oncomplete="window.open('_blank')",它会打开一个新的选项卡,但无法获取pdf文件并显示 "Error 404 Not Found"。

使用primefaces-3.1版本。

谢谢

  <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
     'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>

     <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">


    <h:head>
        <h:outputStylesheet library="base" name='jquery-ui-1.8.16.custom.css' />
    </h:head>
    <h:form target="_blank">
      <p:commandButton value="Run" action="#{bean.createReport}"  />
    </h:form>

    </html>
1个回答

7
尝试设置
ajax="false"

在您的 p:commandButton 上,这样它应该像 h:commandButton 一样运作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接