每当我尝试导航时,我的datascroller只会显示前5条记录。我肯定会犯一些愚蠢的错误..
这是我的xhtml文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/template/BasicTemplate.xhtml">
<ui:define name="content">
<h:form>
<h:panelGrid>
<rich:dataScroller for="sampleData" maxPages="20" id="scroller"
page="#{richBean.scrollerPage}">
<rich:dataTable id="sampleData" value="#{richBean.employees}"
var="loc" rows="5">
<rich:column>
<h:outputText value="#{loc.empId}" />
</rich:column>
<rich:column>
<h:outputText value="#{loc.empName}" />
</rich:column>
<rich:column>
<h:outputText value="#{loc.dept}" />
</rich:column>
</rich:dataTable>
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</html>
和我的java文件
@ManagedBean(name = "richBean", eager = true)
@SessionScoped
public class JavaBeatRichfacesBean {
private List<employee> employees;
private int scrollerPage=1;
public int getScrollerPage() {
System.out.println("getScrollerPage");
return scrollerPage;
}
public void setScrollerPage(int scrollerPage) {
System.out.println("setScrollerPage");
this.scrollerPage = scrollerPage;
}
public JavaBeatRichfacesBean() {
this.employees = new ArrayList<employee>();
employee employee = null;
for (int i = 1; i < 50; i++) {
employee = new employee();
employee.setEmpId(String.valueOf(i));
employee.setEmpName("Name : " + i);
employee.setDept("JSF");
employees.add(employee);
}
}
public List<employee> getEmployees() {
System.out.println(employees.size());
return employees;
}
public void setEmployees(List<employee> employees) {
this.employees = employees;
}
}
EDITED 我注意到的两件事是
任何解释为什么这种情况会有用..