在childwindow中的primefaces filedownload

时间:2015-11-26 03:31:54

标签: primefaces

我在p:filedownload这样的数据表中有primefaces

<p:column>
        <p:commandLink id="downloadLink"
                                style="color:blue;text-decoration:underline; "
                                disabled="#{ShipAttach.deleteSelect}" onclick="trailNewpage();"
                                value="#{ShipAttach.bpmfilename}" ajax="false">
                                <p:fileDownload contentDisposition="inline"
                                    value="#{filedownloadController.fileDownload(ShipAttach)}" />
                            </p:commandLink>
                        </p:column>

当我点击链接时我在同一个窗口中打开文件,我也可以通过指定属性target="_blank"在新选项卡中打开文件我想在Childwindow中打开这些文件,请提前帮助我。

1 个答案:

答案 0 :(得分:0)

我在使用CommandLink打开newTab中的fileDownload时遇到了同样的问题。我被迫使用setTimeout使其工作(但我不明白为什么)。

使用旧代码,该链接将打开具有相同页面的新选项卡,但不会打开文件下载:

<h:commandLink
        onclick="doStuff()"
        target="_blank">
    <p:fileDownload contentDisposition="inline" value="#{myFile}"/>
</h:commandLink>

使用新代码,该链接打开带有文件下载的新标签:

<h:commandLink
        onclick="setTimeout(doStuff, 0)"
        target="_blank">
    <p:fileDownload contentDisposition="inline" value="#{myFile}"/>
</h:commandLink>
相关问题