I have a map like
Map<BigDecimal, String> functions = new HashMap<BigDecimal, String>();
When I try to access the value of map from a JSF page, it displays nothing. I checked the size of map and it returns a number, it seems not empty. Here is the JSF page code
<p:dataTable value="#{bean.permissions}" var="permission">
<p:column>
#{bean.functions[permission.functionId]}
</p:column>
</p:dataTable>
How is this caused and how can I solve it?
BigDecimal
is a bad key for HashMap
, it uses the BigDecimals memory address as the key, so even if you have 2 equal values, its a different key, try using the toString()
of the BigDecimal as the key