Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf DataTable作为复合组件,LazyDataModel不工作_Jsf_Jsf 2_Primefaces_Datatable_Composite Component - Fatal编程技术网

Jsf DataTable作为复合组件,LazyDataModel不工作

Jsf DataTable作为复合组件,LazyDataModel不工作,jsf,jsf-2,primefaces,datatable,composite-component,Jsf,Jsf 2,Primefaces,Datatable,Composite Component,在尝试将PrimeFacesDataTable用作复合组件时,我遇到了一些问题。 下面是我的代码片段: commonDataTable.xhtml: <ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:cc="http://java.sun.com/j

在尝试将PrimeFacesDataTable用作复合组件时,我遇到了一些问题。 下面是我的代码片段: commonDataTable.xhtml:

<ui:component xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://primefaces.org/ui">

    <cc:interface>
        <cc:attribute name="rows" />
        <cc:attribute name="value"
            type="org.primefaces.model.LazyDataModel" />
        <cc:attribute name="var" />
        <cc:attribute name="id" />
        <cc:attribute name="rowStyle" />
    </cc:interface>

    <cc:implementation>
        <p:dataTable value="#{cc.attrs.value}"
            rendered="#{not empty cc.attrs.value}" id="#{cc.attrs.id}"
            paginator="true" rows="25" 
            currentPageReportTemplate="Showing {startRecord}-{endRecord} of     {totalRecords}"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="25,50,100" paginatorPosition="bottom"
            lazy="true" rowStyleClass="#{cc.attrs.rowStyle}">
             <c:set target="#{component}" property="var" value="#{cc.attrs.var}"/>
            <cc:insertChildren />
        </p:dataTable>
    </cc:implementation>
    </ui:component>

index.xhtml:

<ui:composition template="/WEB-INF/template/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:t="http://java.sun.com/jsf/composite/components">

<ui:param name="pageTitle" value="My Page" />

<ui:define name="content">
  <p:fieldset>
     <h2>employee Overview</h2>

     <h:form>
        <p:messages id="messages" showDetail="true" autoUpdate="true"
           closable="true" />
        <p:panel rendered="#{not empty mySummaryBean.employeeRunModel}">
           <t:commonDataTable var="employee" value="#{mySummaryBean.employeeRunModel}" rows="10"
                             id="employeeTable"
                             rowStyle="#{employee.employeeErrorStatus}">

                     .........
           </t:commonDataTable>
        </p:panel>
     </h:form>
  </p:fieldset>
</ui:define>
</ui:composition>

员工概述
.........

有人使用LazyDataModel在复合组件中使用datatable吗?

在使用Primeface之后,我现在可以解决这个问题了。共享解决方案,以便在需要时帮助他人。 commonDataTable.xhtml:

<ui:component xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://primefaces.org/ui">

    <cc:interface>
        <cc:attribute name="rows" />
        <cc:attribute name="value"
            type="org.primefaces.model.LazyDataModel" />
        <cc:attribute name="var" />
        <cc:attribute name="id" />
        <cc:attribute name="rowStyle" />
    </cc:interface>

    <cc:implementation>
        <p:dataTable value="#{cc.attrs.value}"
            rendered="#{not empty cc.attrs.value}" id="#{cc.attrs.id}"
            paginator="true" rows="25" 
            currentPageReportTemplate="Showing {startRecord}-{endRecord} of     {totalRecords}"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="25,50,100" paginatorPosition="bottom"
            lazy="true" rowStyleClass="#{cc.attrs.rowStyle}">
             <c:set target="#{component}" property="var" value="#{cc.attrs.var}"/>
            <cc:insertChildren />
        </p:dataTable>
    </cc:implementation>
    </ui:component>

index.xhtml:

<ui:composition template="/WEB-INF/template/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:t="http://java.sun.com/jsf/composite/components">

<ui:param name="pageTitle" value="My Page" />

<ui:define name="content">
  <p:fieldset>
     <h2>employee Overview</h2>

     <h:form>
        <p:messages id="messages" showDetail="true" autoUpdate="true"
           closable="true" />
        <p:panel rendered="#{not empty mySummaryBean.employeeRunModel}">
           <t:commonDataTable var="employee" value="#{mySummaryBean.employeeRunModel}" rows="10"
                             id="employeeTable"
                             rowStyle="#{employee.employeeErrorStatus}">

                     .........
           </t:commonDataTable>
        </p:panel>
     </h:form>
  </p:fieldset>
</ui:define>
</ui:composition>

员工概述
.........