-
15. Re: Scrollable Datatable rows attribute and pagination
echavet Dec 8, 2008 10:24 AM (in response to vijayamaladoss)Hi vijayamaladoss,
sorry if it doesn't work for you.
I'm a little surprised because I had the same problem. But not only for the pages containing only one record: each time the last page contains less records than the row attribute.
Are you absolutly sure that you did compiled and did replaced the .class file well in the jar library ? -
16. Re: Scrollable Datatable rows attribute and pagination
vijayamaladoss Dec 8, 2008 1:42 PM (in response to vijayamaladoss)I used mvn install and rebuild the richface-ui.jar. To confirm the fix I decompiled the class file to check.
-
17. Re: Scrollable Datatable rows attribute and pagination
vijayamaladoss Dec 8, 2008 9:22 PM (in response to vijayamaladoss)Eric,
Can you tell me which version of Richfaces your were using ?
I am currently trying this 3.2.1 GA -
18. Re: Scrollable Datatable rows attribute and pagination
echavet Dec 9, 2008 3:47 AM (in response to vijayamaladoss)I'm using the 3.2.2GA.
-
19. Re: Scrollable Datatable rows attribute and pagination
vijayamaladoss Dec 10, 2008 11:45 AM (in response to vijayamaladoss)Nope this doesn't work in 3.2.2 GA also.
Can you post you sample xhtml/jsp snippet ? -
20. Re: Scrollable Datatable rows attribute and pagination
echavet Dec 11, 2008 4:26 AM (in response to vijayamaladoss)I've just made the test with row=17 because I had 18 users in my database test. It seems to be working...
<?xml version="1.0" encoding="ISO-8859-1" ?> <jsp:root xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:ui="http://java.sun.com/jsf/facelets" version="2.0"> <ui:composition template="layouts/base_layout.jspx"> <ui:define name="titre">Utilisateurs</ui:define> <ui:define name="header">En tête à définir</ui:define> <ui:define name="mainFrame"> <br/> <h:form> <rich:scrollableDataTable height="512" width="500px" value="#{userBinding}" rows="17" var="user"> <f:facet name="caption"> <h:outputText value="Utilisateurs" /> </f:facet> <rich:column id="id" sortable="false" width="40"> <h:outputText value="#{user.id}" /> </rich:column> <rich:column id="username" sortable="true" width="120" sortBy="#{user.username}"> <f:facet name="header"> <h:outputText value="User Name" /> </f:facet> <h:outputText value="#{user.username}" /> </rich:column> <rich:column id="password" width="120"> <f:facet name="header"> <h:outputText value="User Password" /> </f:facet> <h:outputText value="#{user.password}" /> </rich:column> <f:facet name="footer"> <rich:datascroller id="ds2" renderIfSinglePage="false"></rich:datascroller> </f:facet> </rich:scrollableDataTable> </h:form> </ui:define> <ui:define name="footer"> <h:outputText value="FAQ" /> <h:outputText value="Tutoriels" /> <h:outputText value="Forums" /> </ui:define> </ui:composition> </jsp:root>
beanpackage gov.cg13.ui.security; import gov.cg13.common.security.persistence.User; import gov.cg13.common.security.persistence.UserService; import gov.cg13.ui.components.LabeledProperty; import gov.cg13.ui.components.PaginableTableDataModel; import java.io.Serializable; import java.util.List; import org.richfaces.model.SortOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @Controller("userBinding") public class UserDataModel extends PaginableTableDataModel<User> implements Serializable { private static final LabeledProperty[] LABELED_PROPERTIES = { new LabeledProperty("", "id", "20"), new LabeledProperty("Nom", "username", "250"), new LabeledProperty("Mot de passe", "password", "350") }; public UserService getUserService() { // return userService; return getService(UserService.class); } @Autowired public void setUserService(UserService userService) { // this.userService = userService; // impossible car UserService n'est pas Serializable } @Override public List<User> loadData(int startRow, int endRow, SortOrder sortOrder) { logPaginationData(startRow, endRow, sortOrder); return getUserService().findUsers(startRow, endRow, sortOrder); } @Override public int getRowCount() { return getUserService().count(UserService.USER).intValue(); } protected LabeledProperty[] getLabeledProperties() { return LABELED_PROPERTIES; } @Override public Object getTableTitle() { // TODO Auto-generated method stub return "Utilisateurs"; } }
mother classpublic abstract class PaginableTableDataModel<T> extends ScrollableTableDataModel<T> { static Log log = LogFactory.getLog(PaginableTableDataModel.class); @SuppressWarnings("unchecked") protected <T> T getService(Class<T> clazz) { ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance()); return (T) ctx.getBean(clazz.getSimpleName()); } public static void logPaginationData(int startRow, int endRow, SortOrder sortOrder) { if (log.isDebugEnabled()) { log.debug("datatable demande startRow:" + startRow + ", endRow " + endRow); if (sortOrder != null) { SortField[] fields = sortOrder.getFields(); if ((fields != null) && (fields.length > 0)) { for (SortField field : fields) { log.debug(field.getName() + (field.getAscending() ? " ASC" : " DESC")); } } } } } @Override public abstract List<T> loadData(int startRow, int endRow, SortOrder sortOrder); @Override public abstract int getRowCount(); @Override public Object getWrappedData() { throw new UnsupportedOperationException(); } @Override public void setWrappedData(Object data) { throw new UnsupportedOperationException(); }...