When I use a primefaces p:displayTable in a ui:repeat or a p:dataList, the resulting display is buggy. Buggy means, the first table defines the columns of the following tables and not the DynamicDataTableCatalog-columns-count as expected.
My reputation isn't enough to post a image... (output png on an other website...) So i write the output in simple html:
<div>
<table id="firstTableWhichDefinesTheColum">
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
</table>
<table id="secondTableWithOnlyOneColumn">
<tr>
<td>d</td>
<td>random content or empty, because no data is available</td>
<td>random content or empty, because no data is available</td>
</tr>
</table>
</div>
This is the erroneous code:
<p:dataList value="#{evaluateEntriesMBean.dataTables}"
var="qC" type="definition">
<p:panel header="Übersicht #{qC.catalog.name}"
styleClass="defaultPanelClass subGradient">
<p:dataTable value="#{qC.userAnswers}" var="userAnswer"
tableStyle="margin: auto; width: auto;">
<p:column headerText="Mitarbeiter"
style="text-align: right; width: auto">
<h:outputText value="#{userAnswer.user.geteMail()}" />
</p:column>
<p:columns value="#{qC.columns}" var="column"
columnIndexVar="index"
style="#{evaluateEntriesMBean.getStyleOfAnswer(userAnswer,index)}" >
<f:facet name="header">
<div title="#{column.tooltipText}">
<h:outputText value="#{column.name}" />
</div>
</f:facet>
<div title="#{evaluateEntriesMBean.getTextOfAnswer(userAnswer,index)}" >
<p:graphicImage url="/resources/img/green-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Green'}" />
<p:graphicImage url="/resources/img/yellow-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Yellow'}" />
<p:graphicImage url="/resources/img/red-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Red'}" />
<p:graphicImage url="/resources/img/grey-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Unknown'}" />
</div>
</p:columns>
</p:dataTable>
</p:panel>
</p:dataList>
The datamodels which are used in the view:
public class DynamicDataTableCatalog {
private QuestionCatalogHistory catalog;
private List<ColumnHeader> columns;
private List<UserAnswers> userAnswers;
//...
}
public class UserAnswers {
private User user;
private List<Answer> answers;
//...
}
public class ColumnHeader {
String name;
String tooltipText;
//...
}
When i replace the p:dataList with a ui:repeat, the output is the same. Only the c:forEach works but doesn't support ajax updates...
My dependencies (All used libs including the version):
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
I hope someone can tell me if this is a bug or a wrong implementation I've made... Thank you in advance!
It's a Bug in Primefaces which is not fixed at the moment...