I'm editing data with <p:dataTable>
row editor as below.
<p:dataTable value="#{bean.users}" var="user" editable="true">
<p:ajax event="rowEdit" listener="#{bean.onRowEdit}" />
<p:ajax event="rowEditCancel" listener="#{bean.onRowEditCancel}" />
<p:column>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{user.firstName}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{user.firstName}" />
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
The backing bean is implemented as below.
private List<User> users;
@EJB
private UserService userService;
public List<User> getUsers() {
users = userService.list();
return users;
}
When I enter the new data in the cellEditor and submit it, they are not available in listener method. I noticed that they get overwritten by the data called from the database.
Why does this happen and how can I avoid it?