Posted on

Example usage of CommandLink and Javascript in Primefaces

To open a url in a new tab or window using Javascript:

window.open(url,'_blank');

Whether it is a new tab or a new window, also depends on browser’s setting.

To do some back end job first and then redirect to a new tab or window, for example, to save user’s job and then preview in a new tab/window, we can do the following:

<p:commandLink value="Preview" 
actionListener="#{yourBean.yourActionListener}"
oncomplete="window.open('your-url','_blank');" />
Leave a Reply

Your email address will not be published. Required fields are marked *