0

For some reason my table is not rendered the dynamic columns. I have read the similar post (Primefaces static and dynamic columns in datatable) which is exactly what I'm trying to do. I think I understood well. But it doesn't work for me. Perhaps, I'm missing something.

This is my data object:

    public class DataSeries implements Serializable {
      private String resultType; // Either READ, WRITE or MIX
      private Map<String,String> points; 
      private List<String> columns;  // is fixed {"col1","col2","col3","col4"...}

      public DataSeries(String resultType, List<String> columns, Map<String,String> points) {
          this.resultType = resultType;
          this.points = points;
          this.columns = columns;
      }
      ... Getter and Setter for the aboves
  }

Backing Bean TestResultView

        resultData = new ArrayList<DataSeries>();
        ...
        ... Loop to populate 
        ....   List<String> uniqueLabels = ... (it represent columns and it's fixed length)
            Map<String,String> tuples = new HashMap();
            for (DataPoint point : points) {
                tuples.put(point.name, point.value);
            }

            DataSeries series = new DataSeries(type,uniqueLabels,tuples);              
            resultData.add(series);

Here's my xhtml

                    <p:dataTable id="datalist" value="#{TestResultView.resultData}" var="item" widgetVar="resultsTable">
                        <p:column headerText="Type">
                            <h:outputText value="#{item.resultType}" />
                        </p:column>
                        <p:columns value="#{item.columns}" var="column" headerText="#{column}" >
                            <h:outputText value="#{item.points.get(column)}" />
                        </p:columns>                            
                    </p:dataTable>

Expecting ouput:

    type |  col 1   | col 2    | ... 
    ----------------------------------------------------------------------
    READ |  xxx1    |  yyy1    | ... 
    WRITE|  xxx2    |  yyy2    | ... 
    MIX  |  xxx3    |  yyy3    | ... 

But all I see is:

    type
    ----------------------------------------------------------------------
    READ
    WRITE
    MIX
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
DanD
  • 49
  • 3
  • possible duplicate of [Primefaces static and dynamic columns in datatable](http://stackoverflow.com/questions/25658034/primefaces-static-and-dynamic-columns-in-datatable) – Kukeltje Feb 23 '15 at 07:51

2 Answers2

0

You make exactly the same mistake as in the post you refer to. Look at the first answer there

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
0

I had this problem before. This will probably work:

 <p:columns value="#{item.columns.toArray()}" var="column" headerText="#{column}">
    <h:outputText value="#{item.points.get(column)}" />
</p:columns>