title: refresh datatable when close dialog without need to click on a button jsf2 primefaces
body: <p>I have this dialog : </p>
  
  <pre><code>&lt;p:dialog  header="Commande editée le #{acceuilUserController.selectedMajCommande.dateMaj} par l'#{acceuilUserController.selectedMajCommande.utilisateur.type} #{acceuilUserController.selectedMajCommande.utilisateur.nom} #{acceuilUserController.selectedMajCommande.utilisateur.prenom}" widgetVar="carDialog" resizable="false" id="carDlg"  
                       update="cars" showEffect="fade" hideEffect="explode" modal="true"&gt; 
  </code></pre>
  
  <p>it is displayed when the user click on the button belowint the datatable : </p>
  
  <pre><code>&lt;p:column style="width:40px"&gt;                         
                          &lt;p:commandButton  id="selectButton" action="#{acceuilUserController.refresh()}" update=":form:carDlg" oncomplete="carDialog.show()" icon="ui-icon-search" title="plus de détails"&gt;  
                              &lt;f:setPropertyActionListener value="#{car}" target="#{acceuilUserController.selectedMajCommande}" /&gt;  
                          &lt;/p:commandButton&gt;                       
                      &lt;/p:column&gt; 
  </code></pre>
  
  <p>I want when the user close tis dialog, the method below will be executed : </p>
  
  <pre><code>public String refresh(){
      this.selectedMajCommande.setLu(true);
      System.out.println("je suis la alors : "+this.selectedMajCommande.isLu());
      hch.updateCommandeMaj(selectedMajCommande);
      return "acceuil";
  }
  </code></pre>
  
  <p>it allow to refresh data into the datatable, I succeded to make this with a button in the dialog like this :</p>
  
  <pre><code> &lt;p:commandButton id="confirm" value="fermer" update="cars" oncomplete="carDialog.hide()"
                                       action="#{acceuilUserController.refresh()}" /&gt;
  </code></pre>
  
  <p>but I want to do this only when close the dialog,without the need for this button in the box</p>
  
  <p>here is the datatable that I want to refresh : </p>
  
  <pre><code>&lt;p:dataTable id="cars" var="car" value="#{acceuilUserController.lc_maj}"  tableStyle="width:auto" rowStyleClass="#{(car.lu == false) ? 'red' : null}" &gt;  
  
                      &lt;p:column headerText="Commande N° : " style="width:100px"&gt;  
                          &lt;h:outputText value="#{car.commande.id}" /&gt;  
                      &lt;/p:column&gt;  
  
                      &lt;p:column headerText="Date de mise à jour : " style="width:100px"&gt;  
                          &lt;h:outputText value="#{car.dateMaj}" /&gt;  
                      &lt;/p:column&gt; 
  
                      &lt;p:column headerText="Decision : " style="width:100px"&gt;  
                          &lt;h:outputText value="#{car.decison}" /&gt;  
                      &lt;/p:column&gt; 
  
                      &lt;p:column headerText="Etat : " style="width:100px"&gt;  
                          &lt;h:outputText value="#{car.etat}" /&gt;  
                      &lt;/p:column&gt; 
  
                      &lt;p:column style="width:40px"&gt;                         
                          &lt;p:commandButton  id="selectButton" action="#{acceuilUserController.refresh()}" update=":form:carDlg" oncomplete="carDialog.show()" icon="ui-icon-search" title="plus de détails"&gt;  
                              &lt;f:setPropertyActionListener value="#{car}" target="#{acceuilUserController.selectedMajCommande}" /&gt;  
                          &lt;/p:commandButton&gt;                       
                      &lt;/p:column&gt; 
  
                  &lt;/p:dataTable&gt;        
  </code></pre>
  
  <p>how can achieve this, thank you in advance</p>