JSF 2.0使用外部上下文以及faces-redirect = true打开新的浏览器窗口 [英] JSF 2.0 Opening a new browser window using external context along with faces-redirect=true
问题描述
我正在开发JSF 2.0应用程序.单击时,我在后端bean操作中执行一些逻辑,需要重定向到新窗口中的另一个URL,并在退出该操作之前在原始bean操作中执行一些清理工作.我目前正在将externalContext.redirect()方法与"faces-redirect = true"一起使用(因为在重定向发生后,我需要执行一些清理代码).但是,外部URL在同一窗口中打开.
I am developing a JSF 2.0 application. On click of , I perform some logic in the backend bean action, need to redirect to another URL in a new window, and perform some clean up work in my original bean action before exiting the action. I am currently using externalContext.redirect() method along with "faces-redirect=true" (since I have some clean up code to be executed after the redirect happens). But the external URL is being opened in the same window.
我将要求它在单独的新浏览器窗口中打开,同时还要执行重定向后的清理代码.你能告诉我如何做到吗?
I would require it to open in a separate new browser window, while the clean up code after redirect is executed too. Can you please let me know how this can be done ?
推荐答案
您不能从服务器端打开新的浏览器窗口/标签.这只能从客户端进行.一种方法是将target="_blank"
属性添加到提交按钮所在的HTML表单中.
You cannot open a new browser window/tab from server side on. This can only be done from client side on. One of the ways is adding the target="_blank"
attribute to the HTML form where the submit button is sitting in.
因此,按照JSF的说法,应该是:
So, in JSF terms, that would be:
<h:form target="_blank">
这与支持bean代码所做的任何事情都不相关.它只是在服务器处理HTTP请求时同步运行.
This has further nothing to do with whatever the backing bean code is doing. It just runs in sync while the server is processing the HTTP request.
这篇关于JSF 2.0使用外部上下文以及faces-redirect = true打开新的浏览器窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!