我只是将我的PrimeFaces列标记放入标记的包装器中,但是,Sortby and Filterby El表达式未正确计算,并且不会传递到Load Mether我的lazymodel。
基本上,我有以下标签ex:列:
<ui:composition
xmlns:c="http://java.sun.com/jsp/jstl/core"
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:ang="http://ang.com/jsf/facelets">
<p:column headerText="#{label}" sortable="#{sort}" sortBy="#{property}" filterBy="#{property}" filterable="#{filter}" filterMatchMode="#{filterMatchMode}">
<h:outputText value="#{property}" />
</p:column>
在我的主要代码中,我正在执行以下操作:
<p:dataTable id="mainTable" widgetVar="tblTable" var="c"
value="#{applicationBean.lazyModel}" lazy="true"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
paginator="true" rows="10" style="margin-bottom:20px"
selectionMode="single" selection="#{applicationBean.selected}"
paginatorPosition="bottom" rowKey="#{c.id}">
<ex:column label="First Name" property="#{c.firstName}"
filter="true" sort="true" filterMatchMode="contains" />
但是,当我的方法加载数据在我的懒负载bean中调用时,Sortby和Filterby列以"属性"而不是" firstName"传递。
public List<T> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,Object> filters)
有什么想法,为什么在filterby中没有计算EL表达式?
仅提供您的信息,该列是正确渲染的。我可以看到表中的所有内容,但是当我单击进行排序或过滤时,我会得到不存在属性的例外。
我尝试使用字段="#{property}",而不是sortby and filterby,但是它只是有效对于sortby;当我使用字段属性时,过滤仍然是空的。
解决方案
确保您的标签使用3个元素:字段,排序和filterby;所有这些元素只是接收到字段的名称,而不是var/bean。
XHTML:
<ex:column label="First Name" var="#{c}" field="firstName"
filter="true" sort="true" filterMatchMode="contains" />
组件:
<p:column headerText="#{label}" field="#{field}" sortBy="#{field}"
filterBy="#{field}" sortable="#{sort}" filterable="#{filter}"
filterMatchMode="#{filterMatchMode}">
<h:outputText value="#{var[field]}" />
</p:column>