Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jsf

primefaces

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?

like image 864
userk Avatar asked Jan 16 '23 20:01

userk


1 Answers

A little javascript will help:

<p:button value="Link" onclick="window.open('#{bean.url}'); return false;" />

The EL expression will be replaced before javascript is executed.

like image 166
Matt Handy Avatar answered Jan 28 '23 18:01

Matt Handy