我正在寻找一种解决方案来调用从“foo.xhtml”到“bar.xhtml”的页面导航并同时启动下载对话框。我已经实现了一个可以在我的测试tomcat上运行的解决方案,但是JavaScript已经在目标平台WAS 8.0.0.9上被切断了。在没有JS的情况下在JSF中调用导航和FileDownload
<c:if test="#{Bean.downloadPreconditions()}"> <!-- checks a simple boolean variable which gets set to 'true' after all informations for the download are set-->
<script>
window.onload = function() {
document.getElementById('form:download').onclick();
}
</script>
<h:commandLink id="download"
action="PrimeFaces.monitorDownload(start, stop);">
<p:fileDownload value="#{Bean.downloadFile}"></p:fileDownload>
</h:commandLink>
在此解决方案中,我通过JavaScript开始下载后,我重定向到“f.x.xtml”目标页“bar.xhtml”。
PreRenderView解决方案无法正常工作,因为我之前访问过该视图,并且没有得到新的实例化。
我尝试了几个稍微不同的PrimeFaces.monitorDownload(start, stop);
版本,附带<p:fileDownload>
,以及由backingbean调用的下载,如here所述。
我知道,即时通讯尝试调用2点的请求到服务器只需一次点击。我想知道它是否仍然有可能首先切换到目标视图,然后以自动方式调用下载对话框。