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> ...

Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.