Well, I know that i must choose a field from my object that is unique, like a ID. Then my rowKey is "item.id". This works fine when load all itens in a dataTable, but if I add a new item (this object didn't persisted in database yet) with null ID, it don't apper in my dataTable.
What is the solution for this ? I just can use ID as a rowKey but sometimes i need add a new object with NULL ID (because this is didn't persisted on database yet).
Look my code:
<p:dataTable rowKey="#{item.id}" var="item"
value="#{orcamentoMB.itens}"
emptyMessage="Não foi encontrado nenhum registro"
id="dataTableItens"
selection="#{orcamentoMB.selectedItemOrcamento}"
selectionMode="single" rowIndexVar="rowIndex"
rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'first-row' : 'second-row'}">