I am using Primefaces DataTable, it is using the value from a bean that provide a list. and we display a row for each Item from the list.
As well i have another list which is used to display the values in each row for each of its columns.
The example below works very well.
USING VALUES FROM BEAN
<p:dataTable var="item" value="#{bean.items}">
<p:columns var="value" value="#{bean.values}">
<p:outputLabel value="#{value}"/> <!--[WORKS FINE !!!]-->
</p:columns>
</p:dataTable>
If instead of using the values from the bean, i try to use the values from the item itself it does not display anything !
USING VALUES FROM ITEM ITSELF
<p:dataTable var="item" value="#{bean.items}">
<p:columns var="value" value="#{item.values}">
<p:outputLabel value="#{value}"/> <!--[DOES NOT DISPLAY ANYTHING !!!]-->
</p:columns>
</p:dataTable>
The bean is the following and it display rows in datatable when using the values from there.
@Named("bean")
@ViewScoped
public class Bean implements Serializable
{
private static final long serialVersionUID = 1L;
private List<Item> _items = new LinkedList<>();
private List<String> _values = new LinkedList<>();
public List<Item> getItems() {return _items;}
public void setItems(List<Item> items) {_items = items;}
public List<String> getValues() {return _values;}
public void setValues(List<String> values) {_values = values;}
//[BUILD]
@PostConstruct public void init()
{
_items.add(new Item());
_items.add(new Item());
_items.add(new Item());
}
}
The Item object is the following and it does not display rows when using values from there.
public class Item
{
private List<String> _values = new LinkedList<>();
public List<String> getValues() {return _values;}
public void setValues(List<String> values) {_values= values;}
//[BUILD]
public Item()
{
_values.add("value0");
_values.add("value1");
_values.add("value2");
}
}
Why the primeface datatable does not display any row in the case i use the list of values from an external object like below ???
WORKS FINE !
<p:dataTable var="item" value="#{bean.items}">
<p:columns var="value" value="#{bean.values}"><!--[USING BEAN LIST<STRING> -->
<p:outputLabel value="#{value}"/>
DOES NOT WORKS !
<p:dataTable var="item" value="#{bean.items}">
<p:columns var="value" value="#{item.values}"><!--[USING ITEM LIST<STRING> -->
<p:outputLabel value="#{value}"/>