Data lost when submitting form using ajax PrimeFaces
<p>I'm trying to create a page to display a list of customers and allow user to edit customers' information. Basically, the page will list down all the customer as a table with each row is a customer and there's a edit button per row. When the user click edit button, that row will become a form with 4 fields: Login, First name, Last name and Email for user to edit and submit. In normal case, if I click submit button after modifying any fields or not modifying anything, in phase UPDATE MODEL VALUES, the setter methods of all 4 fields will be called. But if I change the value in Login field, only the setter method for Login field will be called. If I move the Login field after the other 3 fields and modify the Login field's value, all 4 setter methods will be called. Please help to suggest any explanations of this weird behaviour.</p>

<p>Here are my code:</p>

<p>My customer bean class:</p>

<pre><code>public class UserEntity extends BaseEntity {
    private Long userId;
    private String login;
    private String firstName;
    private String lastName;
    private String email;

    //setter and getter methods for all field
    ...
}
</code></pre>

<p>My xhtml page</p>

<pre><code>&lt;ui:repeat id="customers" value="#{myModel.customers}" var="customer"&gt;
    &lt;ui:param name="customerEdit"
        value="#{editMode and myModel.currentCust.login.equals(customer.login) and myModel.currentTenantId.equals(customer.accRoleTenantId)}"&gt;&lt;/ui:param&gt;
    &lt;tr class="ui-widget-content default"&gt;
        &lt;td&gt;
            &lt;h:outputText id="oCustomerLogin"
                style="display:#{!customerEdit ? '' : 'none'}"
                value="#{customer.login}"/&gt;
            &lt;h:inputText id="userLogin" value="#{myModel.currentCust.login}" rendered="#{customerEdit}"/&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;h:outputText id="oCustomerFirstName"
                style="display:#{!customerEdit ? '' : 'none'}"
                value="#{customer.firstName}"/&gt;
            &lt;h:inputText id="userFirstName" value="#{myModel.currentCust.firstName}" rendered="#{customerEdit}"/&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;h:outputText id="oCustomerLastName"
                style="display:#{!customerEdit ? '' : 'none'}"
                value="#{customer.lastName}"/&gt;
            &lt;h:inputText id="userLastName" value="#{myModel.currentCust.lastName}" rendered="#{customerEdit}"/&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;h:outputText id="oCustomerEmail"
                style="display:#{!customerEdit ? '' : 'none'}"
                value="#{customer.email}"/&gt;
            &lt;h:inputText id="userEmail" value="#{myModel.currentCust.email}" rendered="#{customerEdit}"/&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;h:commandLink value="Edit" rendered="#{!customerEdit}"&gt;
                &lt;p:ajax listener="#{myController.editCustomer(customer)}" event="click" resetValues="true" process="@this" update="@form" oncomplete="initJSHandlers();"&gt;&lt;/p:ajax&gt;
            &lt;/h:commandLink&gt;
            &lt;h:commandLink value="Save" rendered="#{customerEdit}"&gt;
                &lt;p:ajax listener="#{myController.save}" event="click" resetValues="true" process="@form" update="@form" oncomplete="initJSHandlers();"&gt;&lt;/p:ajax&gt;
            &lt;/h:commandLink&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/ui:repeat&gt;
</code></pre>

<p>In my controller, there is a model variable, which has list of customers (<code>List&lt;UserEntity&gt; customers</code>) and currentCust (<code>UserEnity currentCust</code>), which is set in the edit method.</p>

<p>So for example, if I has a customer:</p>

<p>Customer 1: Login = "AAA", First Name = "FnA", Last Name = "LnA", Email =  "a@a"</p>

<ul>
<li>If I click Edit at Customer 1 row and after that I click save, in
phase UPDATE MODEL VALUES, setter methods for Login, First Name, Last
Name, Email will be called </li>
<li>If I click Edit at Customer 1 row and
after that I modify First Name/Last name/Email and click save, in
phase UPDATE MODEL VALUES, setter methods for Login, First Name, Last
Name, Email will be called </li>
<li>If I click Edit at Customer 1 row and
after that I modify Login together with First Name/Last name/Email
and click save, in phase UPDATE MODEL VALUES, only setter methods for
Login will be called, which means the input data for the other fields
has not bean set to the bean property.</li>
</ul>