Primefaces数据表过滤和分页问题

时间:2013-06-24 07:55:00

标签: jsf-2 primefaces

我正在使用JSF 2.0和primefaces 3.5。我面临的问题是我在页面上创建了一个数据表..每个东西都能正常工作以及分页和过滤,但是当我将相同的页面包含在模板中时...分页和过滤停止工作..任何关于我的想法这个 代码是

<h:form id="form">
    <p:dataTable var="row" rowKey="row.attackID"
        value="#{attackBean.list}" id="tableAttack" paginator="true"
        rows="10" selection="#{attackBean.selectedAttack}"
        filteredValue="#{attackBean.filteredAttack}"
        rowsPerPageTemplate="5,10,15" selectionMode="single">

        <p:ajax event="rowSelect" update=":centerForm:form:display"
            oncomplete="dlg.show()" />

        <p:column headerText="Attack-ID" filterBy="#{row.attackID}">
            <h:outputText value="#{row.attackID}" />
        </p:column>
        <p:column headerText="Action Name" filterBy="#{row.attackName}">
            <h:outputText value="#{row.attackName}" />
        </p:column>
        <p:column headerText="Defended User" filterBy="#{row.userID}">
            <h:outputText value="#{row.userID}" />
        </p:column>
        <p:column headerText="Action Taken">
            <h:outputText value="#{row.actionTaken}" />
        </p:column>
        <p:column headerText="Attack Time">
            <h:outputText value="#{row.attackTime}" />
        </p:column>
    </p:dataTable>

    <p:dialog id="tDialog" header="Threat info" widgetVar="dlg"
        modal="true" height="250" width="300" showEffect="explode"
        hideEffect="bounce">
        <h:panelGrid id="display" columns="1" cellpadding="4">
            <h:outputText value="Attack ID: #{attackBean.selectedAttack.attackID} " />
            <h:outputText value="Description: #{attackBean.selectedAttack.userID}" />
            <h:outputText
                value="Action Taken: #{attackBean.selectedAttack.actionTaken}" />
        </h:panelGrid>
    </p:dialog>
</h:form>

这里是主要的模板代码

 <h:body style="">
<div id="page" >

        <h:panelGroup id="mainPanel">
        <div id="left" class="bar">
            <ui:insert name="left">
                <ui:include src="commonLeft.xhtml" />
            </ui:insert>
        </div>
        <div id="center">

            <div id="hDiv">
                <ui:insert name="left">
                <ui:include src="commonHeader.xhtml" />
            </ui:insert>
            </div>
            <div id="cDiv">
                <h:form id="centerForm">        
                <h:panelGroup id="centerPanel" render="mainPanel">
                    <ui:include src="#{browse.url}" />
                </h:panelGroup>
                </h:form>
            </div>
        </div>
        <div id="right" >
            <ui:insert name="right">
                <ui:include src="commonFooter.xhtml" />
            </ui:insert>
        </div>
    </h:panelGroup>

</div>      
 </h:body>

1 个答案:

答案 0 :(得分:1)

我假设您在此部分中包含了您的模板:

<h:form id="centerForm">        
    <h:panelGroup id="centerPanel" render="mainPanel">
        <ui:include src="#{browse.url}" />
    </h:panelGroup>
</h:form>

如果是这种情况,那么您就会遇到嵌套表单的问题。这是不允许的,内部表单将从HTML代码中删除(您可以在浏览器的源代码中看到)。您不应该将表单强加于父模板中,并让子项创建他们将要使用的表单。