1 Reply Latest reply on Feb 25, 2011 3:44 PM by jgromero

    rich:columns doubt

    jgromero

      Hi

       

      I´m just starting with richfaces... by the way, beautiful job!

       

      I've been searching for several hours the right way to use rich:columns, but I just don't get what I'm doing wrong. Here's the case:

       

                           <rich:dataTable value="#{listHistResults.resultArea}" var="result" width="500">

                              <rich:columns value="#{listHistResults.areas}" var="area">

                                  <f:facet name="header">

                                      <h:outputText value="#{area}" />

                                  </f:facet>

                                  <h:outputText value="#{result} " />

                              </rich:columns>

                          </rich:dataTable>

       

      As you can see this is something really simple.

      resultArea is an ArrayList of String. area is another an ArrayList of String.

       

      In an example run I obtain:

       

       

      area 1area 2area 3
      result1result1result1
      result2result2result2
      result3result3result3

       

      Reading I believed that the right way could be:

       

                          <rich:dataTable value="#{listHistResults.resultArea}" var="result" width="500">

                              <rich:columns value="#{listHistResults.areas}" var="area" index="ind" id="area#{ind}">

                                  <f:facet name="header">

                                      <h:outputText value="#{area}" />

                                  </f:facet>

                                  <h:outputText value="#{result[ind]} " />

                              </rich:columns>

                          </rich:dataTable>

       

      but obviously when try to iterate through result it gives me an exception, with the message:

       

           The class 'java.lang.String' does not have the property '0'

       

      So, believing I finally understands it, I try declaring resultArea as an ArrayList of an ArrayList of String, but I obtained:

       

      area 1area 2area 3
      result1

      result2

      result3

       

      What I'm looking for here is a one line table.

       

      I'm sure I haven't been able to understand something, but I just don't get what is it, and that's why I ask here for some guidance.

       

      On the other hand, I'm not sure but the url which explains rich:columns have some mistakes?. I mean, in subsection 6.6.3.3, the explanations mention the attributes "begin", "end" among others that are not used in the example.

       

      http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_columns.html

       

      Finally, surfing the svn repository, looking for the source of the demo, I didn´t found anything related to the example of types and models of cars in

      http://livedemo.exadel.com/richfaces-demo/richfaces/columns.jsf;jsessionid=F865F5BF4143D6EE22DC07FDDB4CE6EE?c=columns&tab=usage

      I mean, the java source, because in the page there's the source of the page.

       

      Thanks in advance for reading my post, and for any help you can give me.

       

      Juan Romero

        • 1. rich:columns doubt
          jgromero

          My fault:

           

          I believe (I don't know why.... or why not) each inner List in results match each index in datatable (each outer list fills a column). Something like this:

           

           

           

                  List<String> areas = new ArrayList<String>();

                  List<List<String>> results = new ArrayList<List<String>>();

                  for (Area a : getAreas()){

                      for (ResultArea ra : results.getResultAreas()){

                          if (ra.getArea().getAreaId() == a.getAreaId()){

                              List<String> resultadoArea = new ArrayList<String>();

                              areas.add(a.getDescripcion());

                              resultadoArea.add("" + ra.getValor());

                          }...

                      }...

                  }...

           

           

           

          But the true is each outer list will fill a row. Something like:

           

                  List<String> areas = new ArrayList<String>();

                  List<List<String>> results = new ArrayList<List<String>>();

                  List<String> resultadoArea = new ArrayList<String>();

                  for (Area a : getAreas()){

                      for (ResultArea ra : results.getResultAreas()){

                          if (ra.getArea().getAreaId() == a.getAreaId()){

                              areas.add(a.getDescripcion());

                              resultadoArea.add("" + ra.getValor());

                          }...

                      }...

                  }...

           

          And the rest is just fine... Hopefully I'm being clear, just in case someone gets the same problem