title: Show Primefaces Dialog box after checking condition in Javascript
body: <p>I have a text box which gets the Book ID and deletes the record at button click. If the text box is left empty, it deletes all the records in the database.</p>
  
  <pre><code>&lt;h:inputText id="txtBookID" label="txtBookID" value="#{db_work_Bean.bookID}" /&gt;
  &lt;p:commandButton value="Delete Book"  update="table" 
         action="#{db_work_Bean.doDeleteBook}"&gt;                               
      &lt;f:param name="bukID" value="#{db_work_Bean.bookID}"  style="width:120px;"/&gt;                    
  &lt;/p:commandButton&gt;
  </code></pre>
  
  <p>What I want is to check if the text box is left empty, then it should first show p:confirmDialog to confirm whether to delete all the records or not. I know I'll have to check the value of text box in JavaScript, but how can I,</p>
  
  <ol>
  <li>Call the p:confirmDialog from JavaScript</li>
  <li>Call the "action" method in the managed bean once it is confirmed?</li>
  </ol>
  
  <p>Following is my p:confirmDialog code:</p>
  
  <pre><code>&lt;p:confirmDialog widgetVar="warning" header="You are about to delete all the records!" 
      message="Do you wish to continue?"&gt;
    &lt;p:commandButton value="Yes" type="button" onclick="warning.hide()" 
      actionListener="#{db_work_Bean.changeDeleteAllBooksCheck}" 
      styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/&gt;
    &lt;p:commandButton value="No" type="button" onclick="warning.hide()" 
      styleClass="ui-confirmdialog-no" icon="ui-icon-close"/&gt;
  &lt;/p:confirmDialog&gt;
  </code></pre>