I have a problem with p:dialog. I am using it as a part of my JSF 2.2 application:
<p:dialog id="cpaDialog" width="300px" widgetVar="changePasswordAdmin" header="#{msg['account.password.change']}" draggable="false" resizable="false">
<h:form id="changePasswordAdminForm">
<h:commandButton immediate="true" value="#{msg['cancel']}" onclick="PF('changePasswordAdmin').hide();"/>
<p:commandButton id="submitCpa" update="changePasswordAdminForm" value="#{msg['submit']}" action="#{accountEditBean.changeAdminPassword()}" oncomplete="if (args && !args.validationFailed) changePasswordAdmin.hide()"/>
<!-- THERE ARE REQUIRED FIELD -->
</h:form>
</p:dialog>
Currently I am using p:commandButton to submit my form and close the dialog if validation passes with success. The problem is I would like to use h:commandButton there. You'll probably ask why. Case is simple. I need this button to look like a standard h:commandButton without any Primefaces style classes applied.
Probably you'll tell me: 'remove all the styleclasses from the primefaces button'. I know it's possible (but not so effective) I would prefer to use h:commandButton here if it's possible.
I tried this:
<h:commandButton id="submitCpa" value="#{msg['submit']}" action="#{accountEditBean.changeAdminPassword()}" >
<f:ajax onevent="if (args && !args.validationFailed) changePasswordAdmin.hide()"/>
</h:commandButton>
My problem with using this non-primefaces button is that it closes the dialog each time I press it, not depending on validation success.
Does anyone know how to use h:commandButton in this specific case?