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