title: How to find indication of a Validation error (required="true") while doing ajax command
body: <p>I have a form inside a dialog which I close by clicking on commandbutton with ajax ,</p>
  
  <p>like this</p>
  
  <pre><code>&lt;h:commandButton value="Add" action="#{myBean.addSomething(false)}"
      id="add_something_id" &gt;
      &lt;f:ajax render="@form someTable" execute="@form"
          onevent="closeAddNewSomethingDialogIfSucceeded"&gt;&lt;/f:ajax&gt;
  &lt;/h:commandButton&gt;
  </code></pre>
  
  <p>and here is the js code for closing the dialog </p>
  
  <pre><code>    function closeAddNewSomethingDialogIfSucceeded(data) {
          if(data.status === 'success') {
              $("#dialog_id").dialog("close");
          }
      }
  </code></pre>
  
  <p>No problems till here...</p>
  
  <p>Now I changed some of the dialog form fields into <code>required="true"</code> and now I want to prevent the closing of the dialog of i got validation errors...</p>
  
  <p>But the ajax <code>data.status</code> still reaches its <code>success</code> state , and I can't figure out what indication of validation failure I can hook on...</p>
  
  <p>any ideas?</p>
  
  <p><strong>Thanks to BalusC answer I did the following:</strong></p>
  
  <p>in JSF , added :</p>
  
  <pre><code>    &lt;h:panelGroup id="global_flag_validation_failed_render"&gt;
          &lt;h:outputText id="global_flag_validation_failed" value="true" 
              rendered="#{facesContext.validationFailed}"/&gt;
      &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>the f:ajax was changed into</p>
  
  <pre><code>&lt;f:ajax render="@form someTable global_flag_validation_failed_render"
  </code></pre>
  
  <p>and in js added the following check </p>
  
  <pre><code>if(data.status === 'success') {
      if($("#global_flag_validation_failed").length === 0){
           $("#dialog_id").dialog("close");
      }
  }
  </code></pre>