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
Post a Comment