How to represent nested data in a Primefaces datatable?

Just use another data table inside your column :)

<h:column>
    <h:dataTable var="friend" value="#{user.friends}">
        <h:column>
            <h:outputText value="#{friend.name}"/>
        </h:column>
    </h:dataTable>
</h:column>

This is how it looks on my localhost

enter image description here


Another option is to use ui:repeat inside a column to get all the values of a collection.

Example:

<p:dataTable var="user" value="#{userGroupBacking.users}" id="userTable">

    <p:column headerText="User">
        <h:outputText value="#{user.name}" />
    </p:column>

    <p:column headerText="Groups">
        <ui:repeat var="group" value="#{user.groups}">
            <h:outputText value="#{group.name}" /><br />
        </ui:repeat>
...

Primefaces expandable rows should address your need, only you'll need to get creative with the child row component. You could use prime faces data list component as the child row component. It'll look something like:

   <p:row expansion>
    <p:datalist value ="#{yourTableRowVar.friendslist} Var="friend">
    #{friend.firstName}
    </p:datalist>
   </p:row expansion>