I have a <p:dataTable>
where each row has an inputText like this:
<p:dataTable ... rowIndexVar="row">
<p:column>
<p:inputText value="#{myBean.items[row + 1]}" />
</p:column>
</p:dataTable>
The items
property is a Map<Long, String>
:
private Map<Long, String> items = new HashMap<Long, String>();
When I submit some data and manually iterate over the map, it apparently works:
Iterator itr = items.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry e = (Map.Entry) itr.next();
System.out.println("key: " + e.getKey() + " " + "value: " + e.getValue());
}
I get:
key: 1 value: item1 key: 2 value: item2 key: 3 value: item3 key: 4 value: item4
However, when I try to get a specific item by key
String item = items.get(1);
then I get a null
. Based on the map's contents I should get item1
. How is this caused and how can I solve it?