'JSF h:button or Primefaces p:button - target _blank

How can I set _blank as target of a h:button or p:button?

Right now I have a simple link:

<h:outputLink value="#{bean.url}" target="_blank">
 <h:outputText value="Link" />
</h:outputLink>

But I wanted it to look like a button (a primefaces styled button if possible) so I decided to change it by a p:button.

<p:button value="Link" href="#{bean.url}" />

But now I can't set the target value as I want.

Does anybody has an idea?



Solution 1:[1]

I used :

<h:form target="_blank">
      <p:commandButton value="Run" action="#{bean.createReport}"  />
    </h:form>

and this is ok.

Solution 2:[2]

add ajax="false" to primefaces commandButton set target in p:button, not in form

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex Ricardo
Solution 2