I have dataTable for editing users.
I have commandLink in each row for opening modal dialog with selected user data for editing.
On that dialog I have commandButton for saving user.
I have a problem refreshing dataTable and displaying new edited values for user.
<p:commandButton value="Save" action="#{usersBean.updateUser()}" onclick="PF('editUserDlg').hide();" update=":adminForm:adminTabView:usersDataTable" styleClass="ui-priority-primary" style="float: right;" />
I followed BalusC answer on subject finding out id of component and have no errors in server log.
When I click on Save button I call backing bean method:
public void updateUser() {
int userId = selectedUserView.getId();
User user = adminSessionBean.getMe(userId);
try {
updateUser(user);
LOG.info("User seccessfully updated.");
} catch (Exception exc) {
String message = "Error updating user: " + exc.getMessage();
LOG.error(message);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, message, null));
}
}
and edited user is saved correctly (I've checked in database). Problem is that I don't see new edited user values in dataTable after modal dialog is closed. When I refresh page I see new values for user.
When I add call @PostConstruct init() method after updateUser(user); I see the changed values in dataTable, but I am not sure if this is the correct approach.