简体   繁体   English

Primefaces filterBy和sortBy为空且未评估EL

[英]Primefaces filterBy and sortBy are empty and EL not being evaluated

I am simply putting my Primefaces column tag inside a tagged wrapper like the following, however, the sortBy and filterBy EL expressions are not being calculated properly and not being passed on to the load method in my LazyModel. 我只是将我的Primefaces列标记放在如下所示的带标签的包装器中,但是,sortBy和filterBy EL表达式未正确计算,也没有传递给LazyModel中的load方法。

Basically, I have the following tag ex:column: 基本上,我有以下标签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>

In my main piece of code I am doing the following: 在我的主要代码段中,我正在执行以下操作:

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

However, when my method load data is being called in my Lazy Load bean, the sortBy and filterBy column are being passed as "property" instead of "firstName". 但是,当在我的延迟加载bean中调用我的方法加载数据时,sortBy和filterBy列将作为“属性”而不是“ firstName”传递。

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

Any ideas why the EL expression is not being calculated in the filterBy and sortBy inside a tag? 有什么想法为什么不在标签的filterBy和sortBy中计算EL表达式?

Just for your info, the column is rendered properly. 仅出于您的信息,该列已正确呈现。 I can see all the content inside the table, however when I click to sort or filter I get the exception that property does not exist. 我可以看到表中的所有内容,但是当我单击以进行排序或过滤时,我得到的例外是该属性不存在。

I tried to play with the field="#{property}" instead of sortBy and filterBy, however, it just works for the sortBy; 我尝试使用field =“#{property}”而不是sortBy和filterBy,但是,它只适用于sortBy;。 filter by is still coming empty when I use the field attribute. 当我使用field属性时,filter by仍然为空。

Solution

Make sure your tag use the 3 elements: field, sortBy and filterBy; 确保标签使用3个元素:field,sortBy和filterBy; all these elements just receive the name of the field and not the var/bean. 所有这些元素仅接收字段名称,而不接收var / bean。

XHTML: XHTML:

<ex:column label="First Name" var="#{c}" field="firstName" 
     filter="true" sort="true" filterMatchMode="contains" />

Component: 零件:

<p:column headerText="#{label}" field="#{field}" sortBy="#{field}"
    filterBy="#{field}" sortable="#{sort}" filterable="#{filter}"
    filterMatchMode="#{filterMatchMode}">
        <h:outputText value="#{var[field]}" />
</p:column>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM