There are two solutions for me:
1- If I want to browse a user by user and get a list of friends, in this case I prefer dataList .
<p:dataTable value="#{users.list}" var="u"> <p:column headerText="USER">#{u.name}</p:column> <p:column headerText="FRIENDS"> <p:dataList value="#{u.friends}" var="f"> #{f.name} </p:dataTable> </p:column> </p:dataTable>
2- In the case where I can directly access the list of friends (listFreinds [username, friend]) or when I use the JPQL query :
<p:dataTable value="#{users.listFreinds}" var="u" sortBy="#{u.userName}"> <p:column headerText="USER" groupRow="true">#{u.userName}</p:column> <p:column headerText="FRIENDS">#{u.friend}</p:column> </p:dataTable>
The second case is a new proprietary solution with String Grouping , since v6.0.11
https://www.primefaces.org/showcase/ui/data/datatable/rowGroup.xhtml
source share