p:dataTable与ui:repeat或p:dataList组合的奇怪显示行为

时间:2015-09-17 07:33:50

标签: jsf primefaces datatable uirepeat

当我在ui:repeat或p:dataList中使用素数p:displayTable时,生成的显示有问题。 Buggy意味着,第一个表定义了下列表的列,而不是预期的DynamicDataTableCatalog-columns-count。

我的声誉不足以发布图片...(output png on an other website...)所以我用简单的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="&Uuml;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,目前还没有修复......

1 个答案:

答案 0 :(得分:-1)

感谢Kukeltje,我知道这是一个Primefaces-Bug,目前还没有修复...... https://github.com/primefaces/primefaces/issues/88