title: Primefaces - update not getting triggered while hiding the dialog
body: <p>I have created a simplified version of my app below.</p>
  
  <pre><code>    &lt;h:form&gt;
          &lt;p:commandButton value="ADD NEW" action="#{sampleBean.onAddNew}" oncomplete="PF('addDialog').show()" update=":addForm"/&gt;
      &lt;/h:form&gt;
  </code></pre>
  
  <p>The below dialog opens when the button is clicked.</p>
  
  <pre><code>    &lt;p:dialog widgetVar="addDialog"&gt;
          &lt;h:form id="addForm"&gt;
              &lt;p:messages autoUpdate="true" closable="true"/&gt;
              &lt;p:outputLabel value="Name :"/&gt;
              &lt;p:inputText value="#{sampleBean.name}" required="true" requiredMessage="Name is a required field"/&gt;
              &lt;p:outputLabel value="Address :"/&gt;
              &lt;p:inputText value="#{sampleBean.address}"/&gt;
              &lt;p:commandButton value="Save" action="#{sampleBean.save}" oncomplete="if (args &amp;amp;&amp;amp; !args.validationFailed) PF('addDialog').hide();"/&gt;
              &lt;p:commandButton value="Cancel" action="#{sampleBean.cancel}" immediate="true" oncomplete="PF('addDialog').hide()" update="addForm"/&gt;
          &lt;/h:form&gt;
      &lt;/p:dialog&gt;
  </code></pre>
  
  <p>Here is the backing bean code:</p>
  
  <pre><code>public void onAddNew()
  {
      name = "";
      address = "";
  }
  
  public void save()
  {
      System.out.println("Saving ... " + name + " : " + address);
      name = "";
      address = "";
  }
  
  public void cancel()
  {
      System.out.println("Cancelling ... " + name + " : " + address);
      name = "";
      address = "";
  }
  </code></pre>
  
  <p>The problem i'm facing is: </p>
  
  <p>If i encounter a required field validation error on name field and if address is entered and after that if i hit cancel, i'm invoking the action method "sampleBean.cancel"(to reset both name and address to blank) and then updating the form before hiding the dialog box.</p>
  
  <p>However after hiding the dialog and if i click on ADD NEW again, Its still holding the old state(address value what i entered before).</p>
  
  <p>My need is to clear and display the dialog without any old values. </p>
  
  <p>Could someone point out the issue in my above code?</p>
  
  <p>I'm using Primefaces 5.0</p>
  
  <p>Found one solution to address it however i'm not sure if that's the right way to fix.                 </p>
  
  <pre><code>&lt;p:commandButton value="Cancel" action="#{sampleBean.cancel}" immediate="true" oncomplete="PF('addDialog').hide()" update="addForm"&gt;
        &lt;p:resetInput target="addForm"/&gt;
  &lt;/p:commandButton&gt;
  </code></pre>
  
  <p>Regards.</p>