Luiggi has answered the POST matter. If the report is however available by a GET request, then there are other ways.
Use
window.open()
inoncomplete
.<h:form> ... <p:commandButton action="#{bean.submit}" update="@form" oncomplete="if (args && !args.validationFailed) window.open('reportURL')" /> </h:form>
Or conditionally render a
<h:outputScript>
withwindow.open()
.<h:form> ... <p:commandButton action="#{bean.submit}" update="@form" /> <h:outputScript rendered="#{facesContext.postback and not facesContext.validationFailed}"> window.open('reportURL'); </h:outputScript> </h:form>
Or use PrimeFaces
Primefaces#execute()
withwindow.open()
.public void submit() { // ... PrimeFaces.current().executeScript("window.open('reportURL');"); }
The first way requires the URL to be already definied before submit, the latter two ways allows you to use a dynamic URL like so window.open('#{bean.reportURL}')
.