I want to display a Map<Integer, ArrayList<ObjectBO>>
in a Datatable in Tomahawk. I've tried some possible solutions but nothing seems to be work.
<h:panelGrid style="font-family:verdana;font-size:12pt;color:white" columns="1">
<h:outputText value="Choice 1"></h:outputText>
<t:dataTable newspaperColumns="1" value="#{startupBean.choiceKeys}" newspaperOrientation="horizontal" var="key">
<t:column>
<h:outputText style="font-family:verdana;font-size:10pt;color:white" value="#{choiceMap[key].ObjectBO.displayName}"/>
</t:column>
<t:column>
<h:graphicImage width="50" height="50" id="choice" alt="jsf-sun" url="#{choiceMap[Key].ObjectBO.color_url}" value="#{choiceMap[Key].ObjectBO.color_url}">
</h:graphicImage>
</t:column>
</t:dataTable>
</h:panelGrid>
The backing bean part of it is
public List<Integer> getChoiceKeys() {
System.out.println("in keys");
List<Integer> keys = new ArrayList<Integer>();
keys.addAll(choiceMap.keySet());
System.out.println("keys " + keys.size());
return keys;
}
Kindly let me know how to traverse through the Map via Datatable.
Numbers are in EL treated as Long
. In your code, the key
in #{choiceMap[key]}
is treated as Long
and hence the map key never matches because Integer
is not an instance of Long
. This approach will work if you use Long
instead of Integer
as map key.