0 Replies Latest reply on Jun 29, 2011 9:56 AM by smoking81

    Help constructing a complex dataTable

    smoking81 Newbie

      Hello everybody!
      I've spent the last hours trying to figure how to build a complex dataTable with richfaces.. Unfortunately I am using RF 4.0.0 and all the material i could find online refers to old versions of RF (e.g. http://livedemo.exadel.com/richfaces-demo/richfaces/columns.jsf?c=columns uses rich:columns which is not supported by RF 4.0.0) and I could make no progress until now..


      What I want to do is to build a complex table like this (obviously just the coloured part):



      In brief, the application deals with "Tests" (T1, T2, etc in the figure) which get performed every day on several different machines. In each cell, a X represents a failure and V a success for a given test run. Selecting such X/V symbol will show the test run details (I plan to do this with collapsibleSubTable as soon as the table works).

      In the example, imagine that the user asked to show all the results for test T1 to T5 performed on machine 1 and 2 from 24 till 29 Jun: on 24 Jun T1 had a failure on machine 1 and was successfull on machine 2, on 25 Jun was successfull on both the machines and so on).


      Server side, when the user sets a search filter, a query gets performed which returns a List of TestRun (JPA entities) which in turn gets wrapped by a class extending datamodel. Such class looks a bit (I simplyfied here, I do use generics! ) like this:


      public class TestRunDataModel extends DataModel<TestRun>{
      private List<TestRun> testRunList;
      private DataModel<TestRun> dataModel;
      public TestRunDataModel(List<TestRun> testRunList){
         this.dataModel = new ListDataModel<TestRun>(testRunList);
         this.testRunList = testRunList;
      public List<Test> getPerformedTestsDistinct(){...}
      public List<Date> getExecutionDatesDistinct(){..}
      public List<TestRun> getTestRunsForTestAndDateDistinct(Test performedTest, Date startDate){..}


      For the example, the testRunList looks like this:


      performedTest=T1; machine: M1; date=25 Jun 2011; result=failure 
      performedTest=T1; machine: M2; date=25 Jun 2011; result=success 
      performedTest=T1; machine: M1; date=26 Jun 2011; result=success
      performedTest=T1; machine: M2; date=26 Jun 2011; result=success


      The methods of TestRunDataModel allow to extract only what is needed to build the table. (e.g: getPerformedTestsDistinct()--> {T1, T2, T3, T4, T5}, getTestRunsForTestAndDateDistinct(T1, 25 Jun 2011)-->{ performedTest=T1; machine: M1; date=25 Jun 2011; result=failure;performedTest=T1; machine: M2; date=25 Jun 2011; result=success })


      Finally, I have a bean TestRunController whose relevant code is:


      @ManagedBean(name = "testRunController")
      public class TestRunController implements Serializable {
          private TestRun current;
          private TestRunDataModel items = null;
      public String filterTests(){
      items = new TestRunDataModel(getFacade().getAllTestMatching(current));
      return "ListFilteredTestRuns.xhtml";

      The following code generates a single column instead of several as it should be.

      <rich:dataTable value="#{testRunController.items}" var="filteredTests">
                              <f:facet name="header">
                                          <h:outputText value="Test" />
                                  <a4j:repeat value="#{testRunController.items.executionDatesDistinct}" var="dates">
                                              <h:outputText value="#{dates}" />

      I have tried several possibilities until now but none works: I get always a single column with text= "Test" followed by the dates.. What is wrong in this code?


      Do you know any example which could help me to build my table correctly please?


      Many thanks, bye!