Jsf DataTable作为复合组件,LazyDataModel不工作
在尝试将PrimeFacesDataTable用作复合组件时,我遇到了一些问题。 下面是我的代码片段: commonDataTable.xhtml: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
<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>
员工概述
.........