A data table interacts over a list.
The value of the data table has to be a return list in the query to the database. and the var attribute is every object in that list so you can access its properties.
Example:
Java
class CarrinhoCompraBean {
public List<Item> getItems {
List<Item> items = consultaBanco(idCarrinho);
return items;
}
public static class Item {
// ...
}
}
And in your template, Html
<h:dataTable id="table1" value="#{carrinhoCompraBean.items}" var="item" >
<h:column>
<f:facet name="header">
<h:outputText value="Item" />
</f:facet>
<h:outputText value="#{item.nome}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Preço" />
</f:facet>
<h:outputText value="#{item.preco}" />
</h:column>
</h:dataTable>
javadoc dataTable
datatable primefaces