0

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="&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>

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...

Rasap
  • 47
  • 10
  • i can't see your usage of c:forEach in your posted code. please update. maybe it can help identifying the problem – Fritz Sep 17 '15 at 07:50
  • Without going into too much detail, but you are using quite an old version of PF. Have you tried the example with a more recent version, at best 5.x, in a minimal working example? What is the result then? – Dominik Sandjaja Sep 17 '15 at 07:55
  • When i replace the p:dataList - Tags with and of course the closing-tags, it works, but without ajax. – Rasap Sep 17 '15 at 08:14
  • I've tried this code with the newest primefaces 5.2, but this didn't fixed the error. If it's a bug in a framework, primefaces alone isn't the problem... – Rasap Sep 17 '15 at 08:15
  • Try 5.3-SNAPSHOT or the latest elite release. And also checkthe issue list. Things get fixed from time to time – Kukeltje Sep 17 '15 at 10:04
  • https://github.com/primefaces/primefaces/issues/88 – Kukeltje Sep 17 '15 at 13:20
  • Thank you Kukeltje... That means, that this issue isn't fixed in Primefaces... – Rasap Sep 18 '15 at 07:48
  • No it does not. Look at the status (and my comment below your answer and downvote) – Kukeltje Sep 18 '15 at 08:59
  • @BalusC: is it a real duplicate? Things like this worked in PF 4.0 where they did not have their own UIData implementation. So I personally think the suggestion in the 'duplicate' is not fully valid here. – Kukeltje Sep 18 '15 at 09:22
  • @Kukeltje: OP itself posted that as dupe in initial answer (which is now edited away, ah well) – BalusC Sep 18 '15 at 09:25
  • Sorry I'm new in stackoverflow. Yes, I edited the answer, cause I didn't tested it well enough... – Rasap Sep 18 '15 at 11:00

1 Answers1

-1

Thanks to Kukeltje I know that this is a Primefaces-Bug which isn't fixed at the moment... https://github.com/primefaces/primefaces/issues/88

Rasap
  • 47
  • 10
  • It is 'closed'... So it **is** fixed in an Elite release or snapshot. If you tried those and it still fails for you, create a **new** issue with a testcase – Kukeltje Sep 18 '15 at 08:59