Primefaces dataTable with rowspan
html, jsf, primefaces
Solution
A rock-solid and all flexible solution for custom grids is to use <c:forEach> together with Primefaces <p:panelGrid>:
<html ... xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<p:panelGrid>
<p:row>
<p:column styleClass="ui-state-default" colspan="2"><!-- header -->
<h:outputText value="Some Header"/>
</p:column>
...
</p:row>
<p:row><!-- other header row -->
...
</p:row>
<c:forEach items="#{list}" var="element">
<p:row>
<p:column styleClass="ui-state-default" rowspan="#{list.sublist.someSizeExpression}"><!-- left rowspan -->
<h:outputText value="#{element.name}"/>
</p:column>
<c:forEach items="#{element.sublist}" var="subelement">
<p:column>
<h:selectBooleanCheckbox/>
</p:column>
</c:forEach>
</p:row>
</c:forEach>
</p:panelGrid>
</html>
It looks nice, Command-Buttons and AJAX works in both Head and Cells.
Problem
I'm quite new with JSF primefaces 3.1. I try to build a "complex" table and I cannot find a good solution using dataTable (I need a sorting component). I would like to build a table equivalent to the following HTML representation, using a basic POJO like that: ``` String field1 String field2 List<String> fields3 // 3 items String field4 <table border="1"> <tr> <td rowspan="3">col1</td> <td rowspan="3">col2</td> <td>col3.1</td> <td rowspan="3">col4</td> </tr> <tr> <td>col3.2</td> </tr> <tr> <td>col3.3</td> </tr> </table> ``` I give maybe too little information, so if you need it, please tell me :) I hope that my question is clear. Thank you