In my Java EE 6 / JSF 2 project I have a Map
property advantages
in the Employee
entity:
@ElementCollection
private Map<String, Float> advantages;
The key represents the advantage name and the value represents the cost associated with the advantage name. This is mapped to a table with three columns Employee_Id
, Advantages
and Advantages_Key
. I need to display all map entries in my <p:dataTable>
which shows a List<Employee>
. How can I achieve this?
Provided that your environment supports EL 2.2 (Java EE 6 does), and that #{employee}
in the below example is coming from <p:dataTable var>
, then this should do
<ui:repeat value="#{employee.advantages.entrySet().toArray()}" var="entry">
Name: #{entry.key}, Cost: #{entry.value}
</ui:repeat>
this works for me, and this is my map in bean Map:
<p:dataTable id="dtbAddedRoles" value="#{controllerUserCreationMain.mapUtil.entrySet().toArray()}"
var="roleAdded">
<p:column headerText="Role">
<p:outputLabel value="#{roleAdded.key.roleName}" />
</p:column>
</p:dataTable>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With