primefaces数据表facet标题

时间:2013-04-02 07:25:57

标签: java jsf-2 primefaces

我有这样的数据表:

  <p:dataTable value="#{noteMB.noteList}" var="noteItem" id="noteListTable" 
        rowKey="#{noteItem.hashCode()}" selectionMode="single"  selection="#noteMB.selectedNote}" paginator="true" rows="10" paginatorPosition="top"
        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15">

    <p:column width="300">
       <f:facet name="header">
            <h:outputText value="#{noteItem.name == 'blabla' ? 'true' : 'false' }"  />
       </f:facet> 
            <h:outputText value="#{noteItem.code}"  />
    </p:column>
  </p:dataTable>

我的问题:为什么noteItem在facet name =“header”区域中为空? 当我运行此代码标头(noteItem.name)为false并且列值(noteItem.code)具有值。

1 个答案:

答案 0 :(得分:1)

noteItem是你的var条目。

var="noteItem"

此var属性假设为dataTable的每一行保存变量项。 var将遍历noteList中的每个项目。

正如丹尼尔所说,在h:facet标签期间,甚至没有开始创建行。它是每列的主标题,实际上没有数据表行。 因此,你在那里得到空值。

简而言之,您无法访问face中var属性给出的对象。 因为 facets是行独立的

相关问题