title: Why are fields reset after ajax update with Primefaces
body: <p>On a form I have some personal information (name, address etc.) and a changeListener which updates the salutation and letter salutation according to the gender and last name. If the underlying entity was already stored in the database it works fine. If I'm entering data for a new (not saved) entry the form gets reset after the listener has been called. All data entered is lost, only the salutation, lettersalutation which I modify in the listener and gender, name which I use and attached a ajax call on are kept.</p>
  
  <p>This is a part of the form:</p>
  
  <pre><code>&lt;h:form id="person"&gt;
    &lt;p:panel header="#{msg['prs']}"&gt;
      &lt;h:panelGrid columns="6" cellpadding="4"&gt;
        &lt;h:outputText value="#{msg['prs.salutation']}"/&gt;
        &lt;p:inputText value="#{personBean.selectedPerson.salutation}"/&gt;
  
        &lt;h:outputText value="#{msg['prs.lettersalutation']}"/&gt;
        &lt;p:inputText value="#{personBean.selectedPerson.letterSalutation}"/&gt;
        &lt;p:spacer/&gt;&lt;p:spacer/&gt;
  
        &lt;h:outputText value="#{msg['prs.name']}: "/&gt;
        &lt;p:inputText value="#{personBean.selectedPerson.name}"&gt;
          &lt;p:ajax event="change" update="person"
            listener="#{personBean.selectedPerson.updateSalutation}" /&gt;
        &lt;/p:inputText&gt;
  
        &lt;h:outputText value="#{msg['prs.surname']}: "/&gt;
        &lt;p:inputText value="#{personBean.selectedPerson.surname}"/&gt;
  
        &lt;h:outputText value="#{msg['prs.gender']}: "/&gt;
        &lt;p:selectOneMenu value="#{personBean.selectedPerson.gender}"&gt;
          &lt;f:selectItems value="#{enumHelper.getEnum('Gender')}"/&gt;
           &lt;p:ajax event="change" update="person" 
             listener="#{personBean.selectedPerson.updateSalutation}" /&gt;
        &lt;/p:selectOneMenu&gt;
    &lt;/p:panel&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>In the code I do then the updates. </p>
  
  <pre><code>public void updateSalutation() {
      // simplified
      letterSalutation = "...";
      salutation = "...";
      // outputs for debug
      System.out.println(this.getName()); // --&gt; not null
      System.out.println(this.getSurname()); // --&gt; null
  }
  </code></pre>
  
  <p>Already here in this call surname, which is not attached to a ajax call is null even though data was entered there. The same is true for all the other fields. In my application I'm using Primefaces, JavaEE 1.6 with Wildfly.</p>
  
  <p>What is the reason for that behavior? Is there anything I can change on my calls to prevent this?</p>