6

我有一个数据表:

<p:dataTable id="pDataTableListaRegistros"
             var="registro"
             value="#{arquivoBean.listaRegistros}"
             paginator="true"
             rows="20"
             filteredValue="#{arquivoBean.filteredListaRegistros}"
             styleClass="tabelaCentralizada">

我想获取在过滤器字段“代码”、“数据做注册”和“Usuário”中输入的值,以便在支持 bean 中进行操作。

在此处输入图像描述

4

2 回答 2

7

您可以通过以下方式从数据表中获取过滤器值

  1. 通过绑定或遍历树从视图中获取对数据表的引用。通过绑定,您将拥有:

       <p:dataTable binding="#{arquivoBean.theDataTable}" id="pDataTableListaRegistros" var="registro" value="#{arquivoBean.listaRegistros}" paginator="true" rows="20" filteredValue="#{arquivoBean.filteredListaRegistros}" styleClass="tabelaCentralizada"/>
    

    在你的支持bean中:

       DataTable theDataTable = new DataTable();
       //getter and setter
    
  2. 从绑定

       Map<String, String> theFilterValues = theDataTable.getFilters(); //This returns a map of column-filterText mapping.
    
于 2013-03-19T00:38:05.630 回答
1

您可以将地图添加到您的 bean,例如:

private Map<String, Serializable> filterValues = new HashMap<>();

filterValue并使用 的属性将值绑定到地图p:column,例如:

<p:column headerText="Name"
          sortBy="#{item.name}"
          filterBy="#{item.name}"
          filterMatchMode="contains"
          filterValue="#{yourBean.filterValues['name']}">
  <h:outputText value="#{item.name}" />
</p:column>

此解决方案的优点是更新表时将保留这些值。

于 2017-03-09T11:59:50.253 回答