Primefaces filterBy和sortBy为空,EL未被评估

时间:2017-02-17 11:41:28

标签: jsf primefaces jsf-2

我只是将我的Primefaces列标记放在标记的包装器中,如下所示,但是,sortBy和filterBy EL表达式没有正确计算,也没有传递给我的LazyModel中的load方法。

基本上,我有以下标记ex:column:

<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" />

但是,当我的Lazy Load bean中调用我的方法加载数据时,sortBy和filterBy列将作为&#34; property&#34;而不是&#34; firstName&#34;。

public List<T> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,Object> filters)

为什么没有在标签中的filterBy和sortBy中计算EL表达式的任何想法?

只是为了您的信息,列正确呈现。我可以看到表中的所有内容,但是当我点击排序或过滤时,我得到了属性不存在的异常。

我尝试使用字段=&#34;#{property}&#34;而不是sortBy和filterBy,它只是工作 对于sortBy;当我使用field属性时,filter by仍然是空的。

1 个答案:

答案 0 :(得分:0)

解决方案

确保您的代码使用3个元素:field,sortBy和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>
相关问题