rich:dataScroller只显示第一页

时间:2014-01-29 06:56:20

标签: jsf-2 richfaces

每当我尝试导航时,我的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 我注意到的两件事是

  1. 我每次都要刷新以更改页面导航。
  2. 如果使用h:dataTable而不是rich:dataTable ..它正在工作
    好的,令人惊讶的..
  3. 如果我在rich中添加execute =“@ form”render =“@ form”:datatable工作正常但我双击一切..
  4. 任何解释为什么这种情况会有用..

0 个答案:

没有答案