Code: Select all
<ui:composition>
<h:form id="userTableForm" prependId="false">
<p:dataTable id="user_table" var="user" value="#{userTableBean.lazyUserList}"
paginator="true" rows="5" lazy="true" dynamic="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
.
.
. (other columns for User object here)
.
<p:column headerText="Edit">
<h:commandLink type="submit" action="#{userTableBean.deleteUser}">
<f:param name="paramUserId" value="#{user.id}"/>
<h:outputText value="delete" />
</h:commandLink>
</p:column>
</p:dataTable>
</h:form>
</ui:composition>
Code: Select all
public class UserTableBean extends User {
private UserDAO userDAO;
private AuthorityDAO authorityDAO;
private ExternalContext jsfContext;
private LazyDataModel<User> lazyUserList;
public UserTableBean() {
System.out.println("++++++++++++++++++++++++++++++++++++ UserTableBean ++++++++++++++++++++++++++++++++"); // this is shown in the console so my bean constructor is being called
}
public void setUserDAO(UserDAO userDAO) {
this.userDAO = userDAO;
}
public void setAuthorityDAO(AuthorityDAO authorityDAO) {
this.authorityDAO = authorityDAO;
}
public void setLazyUserList(LazyDataModel<User> lazyUserList) {
this.lazyUserList = lazyUserList;
}
public String deleteUser() throws SQLException { // this method does not get called at all if I'm using lazy loading of my User object! But it works fine otherwise
jsfContext = FacesContext.getCurrentInstance().getExternalContext();
Long id = Long.parseLong(jsfContext.getRequestParameterMap().get("paramUserId"));
userDAO.deleteUserById(id);
return "delete";
}
public LazyDataModel<User> getLazyUserList() {
return lazyUserList;
}
}
Code: Select all
<managed-bean>
<managed-bean-name>userTableBean</managed-bean-name>
<managed-bean-class>com.wegc.bean.UserTableBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>userDAO</property-name>
<value>#{userDAO}</value>
</managed-property>
<managed-property>
<property-name>authorityDAO</property-name>
<value>#{authorityDAO}</value>
</managed-property>
<managed-property>
<property-name>lazyUserList</property-name>
<value>#{userDAO.lazyUserList}</value>
</managed-property>
</managed-bean>
I know this issue has been asked countless times like in viewtopic.php?f=3&t=3346&p=15353&hilit= ... ink#p15353 and viewtopic.php?f=3&t=13613&p=41158&hilit ... ink#p41158 but I can't get it to work at all with PrimeFaces 3.2... Please tell me what to do to get this working, i know this was supposed to have been fixed in PF 2.2 and above versions (i.e. viewtopic.php?f=3&t=5893&p=25026&hilit= ... ink#p25026) but I'm probably doing something wrong here because mine is not working