1 Reply Latest reply on Feb 4, 2009 9:06 AM by Ilya Shaikovsky

    Not possible to put several <rich:columns/> elements inside

    Lukas Eder Newbie

      Intuitively, I would expect that I can freely mix <rich:column/> and <rich:columns/> elements inside a <rich:dataTable/>. This, however, is not true. Only one <rich:columns/> element is allowed for each <rich:dataTable/>

      This is what I would like to do, essentially:

      <rich:dataTable value="#{sandbox.records}" var="record">
       <rich:columns value="#{sandbox.columnsLeft}" var="column">
       <f:facet name="header">
       <h:outputText value="#{column}" />
       </f:facet>
       <h:outputText value="#{record[column]}"/>
       </rich:columns>
       <rich:column>
       <f:facet name="header">
       <h:outputText value="separator" />
       </f:facet>
       <h:outputText value="separator"/>
       </rich:column>
       <rich:columns value="#{sandbox.columnsRight}" var="column">
       <f:facet name="header">
       <h:outputText value="#{column}" />
       </f:facet>
       <h:outputText value="#{record[column]}"/>
       </rich:columns>
      </rich:dataTable>


      Where this is the content of the sandbox bean:

      package ch.ergon.telcobill.view.bean;
      
      import java.util.ArrayList;
      import java.util.Arrays;
      import java.util.HashMap;
      import java.util.List;
      import java.util.Map;
      
      public class SandboxBean {
       public List<Map<String, String>> getRecords() {
       List<Map<String, String>> result= new ArrayList<Map<String,String>>();
      
       int max= 3;
       for (int i= 0; i < max; i++) {
       Map<String, String> record= new HashMap<String, String>();
      
       record.put("left1", Integer.toString(i));
       record.put("left2", Integer.toString(i));
      
       record.put("right1", Integer.toString(max - i));
       record.put("right2", Integer.toString(max - i));
      
       result.add(record);
       }
      
       return result;
       }
      
       public List<String> getColumnsLeft () {
       return Arrays.asList("left1", "left2");
       }
      
       public List<String> getColumnsRight () {
       return Arrays.asList("right1", "right2");
       }
      }


      Only the second columns element is actually rendered (right1, right2). The first one is ignored (left1, left2). When I looked inside the code, I found out that the ColumnsTag transforms itself into several HtmlColumn components. Somewhere in the transformation of the second ColumnsTag, however, the HtmlColumn components of the first tag are lost