O'Reilly logo

PrimeFaces Cookbook - Second Edition by Oleg Varaksin, Mert Çalışkan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using subTable for grouping

A helper component, subTable can be used to group row data inside a table.

How to do it…

A basic definition of a table that contains subTable is given here:

<p:dataTable value="#{dataTableBean.boxers}" var="boxer"> <f:facet name="header"> Boxers </f:facet> <p:columnGroup type="header"> <p:row> <p:column rowspan="2" headerText="Boxer" /> <p:column colspan="2" headerText="Stats" /> </p:row> <p:row> <p:column headerText="Wins" /> <p:column headerText="Losses" /> </p:row> </p:columnGroup> <p:subTable var="stats" value="#{boxer.stats}"> <f:facet name="header"> <h:outputText value="#{boxer.name}" /> </f:facet> <p:column> <h:outputText value="#{stats.match}" /> </p:column> <p:column> <h:outputText value="#{stats.win}" /> </p:column> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required