Nesting tables
It's most likely that you won't need to display a table inside another table, but there are cases when this workaround can be useful in obtaining a clear presentation of the data. For example, nested collections can be presented as nested tables as follows:
HashMap<Players, HashSet<Trophies>> dataHashMap = new HashMap<>();
Here, players are stored in HashMap
as keys, and each player has a collection (HashSet
) of trophies. Each HashSet
value is a value in HashMap
. Therefore, you need to display the table of players; however, you need to display each player's trophies. This can be achieved as shown in the following code:
<h:dataTable value="#{playersBean.dataHashMap.entrySet()}" var="t"> <h:column> <f:facet name="header">Ranking</f:facet> #{t.key.ranking} </h:column> <h:column> <f:facet name="header">Name</f:facet> #{t.key.player} </h:column> ... <h:column> <f:facet...