jsf - How to open an arbitrary URL in new window using a PrimeFaces button -


i have below output link job:

<h:outputlink value="#{verdocumentocontroller.url()}" target="_blank">     show document </h:outputlink> 

it opens url obtained bean property in new window.

however, i'd turn link button in primefaces look'n'feel. tried below:

<p:commandbutton value="show document" action="#{verdocumentocontroller.url()}"      onclick="form.target='_blank'" ajax="false" /> 

but reopens current page in new window , not url specified bean property. how can achieve anyway?

the <p:commandbutton> submits post request url specified parent <h:form>, defaults indeed current request url (you know, "postback"). action attribute invokes bean method , uses returned value navigation case outcome. url not represent sensible navigation case outcome.

just use window.open() instead on simple <p:button>.

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

you can on <p:commandbutton>, that's unnecessarily overcomplicated.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -