You can confirm window.open and not return false
<a4j:commandButton id="elementDetailsButton" onclick="if (confirm('Are you sure? Unsaved data will be lost')) { window.open(URL, ...) } else { return false }" (...) />
"Else" is optional, possibly optional.
Or you can change the purpose of the form. I donβt remember very well if this is the correct syntax ...
<a4j:commandButton id="elementDetailsButton" onclick="this.form.taget='_blank'" (...) />
... or something like that.
Changing the purpose of the form will give you a good problem. The rest of the application will focus on a new window. To solve this problem, I did <h:commandLink/> to close the window (modalPanel) and reset the form target.
I used this (trick) to open .pdf reports inside <rich:modalPanel/> using <iframe/> .
But I'm not sure that changing the purpose of the form will be useful for your problem.
Renan
source share