用dataScroller多个数据表的用法每个导致dataScroller故障(Usage of m

2019-10-19 06:24发布

我有三个数据表JSF页面。 他们每个人都有一个相关的dataScroller。 当查看页面只有最后dataScroller(底部)的作品。 其他人只能加载在自己dataScroller选择任何页面时,在最后的dataTable选择的页面。

我已经调试使用Firebug的页面,我什么也没找到有关。 也没有我发现任何线索在这里或在有关如何解决这一问题的其他论坛。

我还张贴了一些代码,以防万一它可能是有帮助的。 提前致谢:

homepage.xhtml

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:c="http://java.sun.com/jstl/core">

<ui:composition template="layouts/template.jsf">
    <ui:define name="body">
        <h3>#{msg.homepageCaption1}</h3>
        <h:form id="form">
            <div>
                <rich:dataTable value="#{HomepageBean.firstTable}"
                    var="tOne" id="tableOne" rows="5">
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.firstColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.firstColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.secondColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.secondColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.thirdColumn}" />
                        </f:facet>
                        <h:outputText value="This is an String" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fourthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.fourthColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fifthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.fifthColumn}" />
                    </rich:column>
                </rich:dataTable>
                <rich:dataScroller for="tableOne"
                    pageIndexVar="#{HomepageBean.firstTablePage}"
                     ajaxSingle="false">
                    <f:facet name="previous">
                        <h:outputText value="&lt;" />
                    </f:facet>
                    <f:facet name="next">
                        <h:outputText value="&gt;" />
                    </f:facet>
                    <f:facet name="fastrewind">
                        <h:outputText value="&lt;&lt;" />
                    </f:facet>
                    <f:facet name="fastforward">
                        <h:outputText value="&gt;&gt;" />
                    </f:facet>
                </rich:dataScroller>
            </div>
            <div>
                <h3>#{msg.homepageCaption2}</h3>
                <rich:dataTable
                    value="#{HomepageBean.secondTable}" var="tTwo"
                    id="tableTwo" rows="5">
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.firstColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.firstColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.secondColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.secondColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.thirdColumn}" />
                        </f:facet>
                        <h:outputText value="This is an string" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fourthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.fourthColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fifthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.fifthColumn}" />
                    </rich:column>
                </rich:dataTable>
                <rich:dataScroller for="tableTwo"
                    pageIndexVar="#{HomepageBean.secondTablePage}"
                    ajaxSingle="false">
                    <f:facet name="previous">
                        <h:outputText value="&lt;" />
                    </f:facet>
                    <f:facet name="next">
                        <h:outputText value="&gt;" />
                    </f:facet>
                    <f:facet name="fastrewind">
                        <h:outputText value="&lt;&lt;" />
                    </f:facet>
                    <f:facet name="fastforward">
                        <h:outputText value="&gt;&gt;" />
                    </f:facet>
                </rich:dataScroller>
            </div>
            <div>
                <h3>#{msg.homepageCaption3}</h3>
                <rich:dataTable
                    value="#{homepageBean.thirdTable}" var="tThree"
                    id="tableThree" rows="5">
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.firstColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.firstColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.secondColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.secondColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.thirdColumn}" />
                        </f:facet>
                        <h:outputText value="This is an string" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fourthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.fourthColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fifthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.fifthColumn}" />
                    </rich:column>
                </rich:dataTable>
                <rich:dataScroller for="tableThree"
                    pageIndexVar="#{homepageBean.thirdTablePage}"
                    ajaxSingle="false">
                    <f:facet name="previous">
                        <h:outputText value="&lt;" />
                    </f:facet>
                    <f:facet name="next">
                        <h:outputText value="&gt;" />
                    </f:facet>
                    <f:facet name="fastrewind">
                        <h:outputText value="&lt;&lt;" />
                    </f:facet>
                    <f:facet name="fastforward">
                        <h:outputText value="&gt;&gt;" />
                    </f:facet>
                </rich:dataScroller>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
</html>

homepageBean.java

package somepackage.bean;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import somepackage.service.HomepageService;
import somepackage.viewdto.ViewDTO;

@Component("HomepageBean")
@Scope("request")
public class HomepageBean {

    private List<ViewDTO> firstTable;
    private List<ViewDTO> secondTable;
    private List<ViewDTO> thirdTable;
    private int firstTablePage;
    private int secondTablePage;
    private int thirdTablePage;
    @Autowired
    private HomepageService homepageService;


    public List<ViewDTO> getFirstTable() {
        return firstTable;
    }
    public void setFirstTable(List<ViewDTO> firstTable) {
        this.firstTable = firstTable;
    }
    public List<ViewDTO> getSecondTable() {
        return secondTable;
    }
    public void setSecondTable(List<ViewDTO> secondTable) {
        this.secondTable = secondTable;
    }
    public List<ViewDTO> getThirdTable() {
        return thirdTable;
    }
    public void setThirdTable(List<ViewDTO> thirdTable) {
        this.thirdTable = thirdTable;
    }
    public int getFirstTablePage() {
        return firstTablePage;
    }
    public void setFirstTablePage(int firstTablePage) {
        this.firstTablePage = firstTablePage;
    }
    public int getSecondTablePage() {
        return secondTablePage;
    }
    public void setSecondTablePage(int secondTablePage) {
        this.secondTablePage = secondTablePage;
    }
    public int getThirdTablePage() {
        return thirdTablePage;
    }
    public void setThirdTablePage(int thirdTablePage) {
        this.thirdTablePage = thirdTablePage;
    }
    public HomepageService getHomepageService() {
        return homepageService;
    }
    public void setHomepageService(HomepageService homepageService) {
        this.homepageService = homepageService;
    }

}

Answer 1:

这个问题解决了嵌套一个panelGrid的内部的每个表(不知道这是否应该是完全正确的做法,但它的工作):

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:c="http://java.sun.com/jstl/core">

<ui:composition template="layouts/template.jsf">
    <ui:define name="body">
        <h3>#{msg.homepageCaption1}</h3>
        <h:form id="form">
            <h:panelGrid columnClasses="acent">
                <rich:dataTable value="#{HomepageBean.firstTable}"
                    var="tOne" id="tableOne" rows="5">
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.firstColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.firstColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.secondColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.secondColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.thirdColumn}" />
                        </f:facet>
                        <h:outputText value="This is an String" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fourthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.fourthColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fifthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tOne.fifthColumn}" />
                    </rich:column>
                </rich:dataTable>
                <rich:dataScroller for="tableOne"
                    pageIndexVar="#{HomepageBean.firstTablePage}"
                     ajaxSingle="false">
                    <f:facet name="previous">
                        <h:outputText value="&lt;" />
                    </f:facet>
                    <f:facet name="next">
                        <h:outputText value="&gt;" />
                    </f:facet>
                    <f:facet name="fastrewind">
                        <h:outputText value="&lt;&lt;" />
                    </f:facet>
                    <f:facet name="fastforward">
                        <h:outputText value="&gt;&gt;" />
                    </f:facet>
                </rich:dataScroller>
            </h:panelGrid>
            <h:panelGrid columnClasses="acent">
                <h3>#{msg.homepageCaption2}</h3>
                <rich:dataTable
                    value="#{HomepageBean.secondTable}" var="tTwo"
                    id="tableTwo" rows="5">
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.firstColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.firstColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.secondColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.secondColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.thirdColumn}" />
                        </f:facet>
                        <h:outputText value="This is an string" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fourthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.fourthColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fifthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tTwo.fifthColumn}" />
                    </rich:column>
                </rich:dataTable>
                <rich:dataScroller for="tableTwo"
                    pageIndexVar="#{HomepageBean.secondTablePage}"
                    ajaxSingle="false">
                    <f:facet name="previous">
                        <h:outputText value="&lt;" />
                    </f:facet>
                    <f:facet name="next">
                        <h:outputText value="&gt;" />
                    </f:facet>
                    <f:facet name="fastrewind">
                        <h:outputText value="&lt;&lt;" />
                    </f:facet>
                    <f:facet name="fastforward">
                        <h:outputText value="&gt;&gt;" />
                    </f:facet>
                </rich:dataScroller>
            </h:panelGrid>
            <h:panelGrid columnClasses="acent">
                <h3>#{msg.homepageCaption3}</h3>
                <rich:dataTable
                    value="#{homepageBean.thirdTable}" var="tThree"
                    id="tableThree" rows="5">
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.firstColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.firstColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.secondColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.secondColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.thirdColumn}" />
                        </f:facet>
                        <h:outputText value="This is an string" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fourthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.fourthColumn}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.fifthColumn}" />
                        </f:facet>
                        <h:outputText value="#{tThree.fifthColumn}" />
                    </rich:column>
                </rich:dataTable>
                <rich:dataScroller for="tableThree"
                    pageIndexVar="#{homepageBean.thirdTablePage}"
                    ajaxSingle="false">
                    <f:facet name="previous">
                        <h:outputText value="&lt;" />
                    </f:facet>
                    <f:facet name="next">
                        <h:outputText value="&gt;" />
                    </f:facet>
                    <f:facet name="fastrewind">
                        <h:outputText value="&lt;&lt;" />
                    </f:facet>
                    <f:facet name="fastforward">
                        <h:outputText value="&gt;&gt;" />
                    </f:facet>
                </rich:dataScroller>
            </h:panelGrid>
        </h:form>
    </ui:define>
</ui:composition>
</html>


文章来源: Usage of multiple dataTables with a dataScroller each leads to dataScroller malfunction