In HTML, a link which opens the given URL in a new window/tab via a GET request is to be achieved using <a ... target="_blank">
.
In JSF you can just write down plain vanilla HTML:
<a href="#{request.contextPath}/2.xhtml" target="_blank">Open 2.xhtml in new window</a>
You can also use <h:outputLink>
, which is only beneficial if you ever want to use its rendered
attribute:
<h:outputLink value="#{request.contextPath}/2.xhtml" target="_blank">Open 2.xhtml in new window</h:outputLink>
You can also use <h:link>
which can take a navigation outcome instead of an URL, JSF will then generate the right URL:
<h:link value="Open 2.xhtml in new window" outcome="2" target="_blank" />
The bean scope is irrelevant to this all. Just choose the right one for the data it holds. The <h:commandLink>
is insuitable as it fires a POST request instead of a GET request.