JSF 2.0 Opening a new browser window using external context along with faces-redirect=true

╄→гoц情女王★ 提交于 2019-12-12 21:03:12

问题


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 ?


回答1:


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.

So, in JSF terms, that would be:

<h:form target="_blank">

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.



来源:https://stackoverflow.com/questions/18644465/jsf-2-0-opening-a-new-browser-window-using-external-context-along-with-faces-red

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!