当我在ui:repeat或p:dataList中使用primefaces p:displayTable时,结果显示有问题。有bug的意思是,第一个表定义了下面表的列,而不是预期的dynamicdatatableccatalogg -columns-count。
我的名声还不足以发一张图…(在其他网站输出PNG…)所以我把输出写成简单的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>
错误代码:
<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>
视图中使用的数据模型:
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;
//...
}
当我用ui:repeat替换p:dataList时,输出是相同的。只有c:forEach工作,但不支持ajax更新…
我的依赖项(所有使用过的库,包括版本):
<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>
我希望有人能告诉我,如果这是一个错误或错误的实现我做了…提前感谢!
这是Primefaces的一个Bug,目前还没有修复…
感谢Kukeltje,我知道这是一个Primefaces-Bug,目前还没有修复…https://github.com/primefaces/primefaces/issues/88