Primefaces onclick and onsuccess differences

jsf, primefaces

Solution

I have noticed that onsuccess for PrimeFaces command button does not work. The oncomplete however works and does the needful even if there is an error , such as in my case shows a success dialog even if there is an error in my business logic. Tried to use onsuccess but doesn't work. You could try oncomplete as below:

<p:commandButton value="this button" update="growlMain"
                 actionListener="#{myBean.businesslogic}" 
                 onstart="ajaxDialog.show();"
                 oncomplete="ajaxDialog.hide(); window.open('./report.jsp', '_newtab');"/>

Problem

I have the following situation: after clicking a button, some business logic is done and after it is done, a new tab with a report should be visible. ``` <p:commandButton value="this button" update="growlMain" actionListener="#{myBean.businesslogic}" onstart="ajaxDialog.show();" oncomplete="ajaxDialog.hide();" onsuccess="window.open('./report.jsp', '_newtab');" /> ``` This does not work :( If the business logic only lasts some milliseconds, the following works: ``` <p:commandButton value="this button" update="growlMain" actionListener="#{myBean.fastbusinesslogic}" onclick="window.open('./report.jsp', '_newtab');" /> ``` the onclick opens a new tab, also things like onstart but it doesn't work with onsuccess or oncomplete. Why? And is there a solution for business logic that lasts some seconds?

Original source