Reputation: 885
i have datatable like this :
<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>
my question: why noteItem is null in facet name="header" area ? when i run this code header(noteItem.name) is false and column value(noteItem.code) has a value.
Upvotes: 1
Views: 5831
Reputation: 582
noteItem is your var entry.
var="noteItem"
This var attribute is suppose to hold the variable item for each row of the dataTable
.
var will iterate through every item in your noteList
.
And as said by Daniel, during h:facet
tag, creating rows is not even started. It is the main header of each column, where there is actually no datatable row.
Hence you get the null value there.
In short, you cannot access the object given by var attribute in facets. Because facets are row independent.
Upvotes: 2