I am trying to use a simple facet function that allows a user to edit row data in a table itself. I followed this link to achieve it:
http://www.primefaces.org/showcase/ui/datatableRowEditing.jsf
When I tell the edit user, the newly entered values โโare not sent to the bean. It still shows only old values.
My code in JSF:
<p:dataTable value="#{mybean.userList}" var="item" id="dataTab" widgetVar="usersTable" tableStyleClass="data" paginator="true" rows="5" filteredValue="#{userController.filteredUsers}" editable="true" rowKey="#{item}"> <p:ajax event="rowEdit" listener="#{mybean.onEdit}" update=":userForm:growl" /> <p:ajax event="rowEditCancel" listener="#{mybean.onCancel}" update=":userForm:growl" /> <f:facet name="header"> <p:outputPanel> <h:outputText value="Search all fields:" /> <p:inputText id="globalFilter" onkeyup="('usersTable').filter()" style="width:150px" /> </p:outputPanel> </f:facet> <p:column sortBy="#{item.firstName}" filterBy="#{item.firstName}" filterMatchMode="startsWith"> <p:cellEditor> <f:facet name="header"> <h:outputText value="First Name" /> </f:facet> <f:facet name="output"> <h:outputText value="#{item.firstName}" /> </f:facet> <f:facet name="input"> <p:inputText value="#{item.firstName}" style="width:100%"/> </f:facet> </p:cellEditor> </p:column> <p:column sortBy="#{item.lastName}" filterBy="#{item.lastName}" filterMatchMode="startsWith"> <p:cellEditor> <f:facet name="header"> <h:outputText value="Last Name" /> </f:facet> <p:column headerText="Update" style="width:6%"> <p:rowEditor /> </p:column> </p:dataTable>
My bean code:
public String onEdit(RowEditEvent event) { User user=(User)event.getObject()); user.getFirstName(); }
in bean to get the list in ui:
public List<UserBean> getUsersList(){ List<UserBean> retval = new ArrayList<>(); for (Object[] tuple : myFacade.getUserList()) { UserBean ub = new UserBean(); ub.setFirstName((String) tuple[0]); ub.setLastName((String)tuple[1]); ub.setEmailAddress((String)tuple[2]); ub.setOfficeNumber((String)tuple[3]); ub.setRole((String)tuple[4]); retval.add(ub); } return retval; }
I tried the suggestions that were indicated in some posts, but they did not work. Can anyone let me know how I can get new values. I am using glassfish 4.0, primefaces 3.5.
source share