3
votes

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

1 Answers

4
votes

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.