11 Replies Latest reply on Mar 22, 2011 4:09 AM by ilya_shaikovsky

    How to iterate a List<List<String>> uisng rich:dataTable component

    sri_kanthu

      Dear All,

       

      kindly help me!

      How to iterate a List<List<String>> uisng rich:dataTable component.

       

      I am having the below List<List<String>>

       

      [[RequestId, Name, Dob,SSN.MRN], [mothername,fatherName,spousename], [Address, HouseNo, City, State, Country, Pincode], [PhoneNo, Fax], [EmailId]]

       

       

      My Requirement of displaying the above list like below:

      The below display is by using c;forEach and normal html table element. How to get the below like display using rich:dataTable component?

       

                     table.jpg

        • 1. How to iterate a List<List<String>> uisng rich:dataTable component
          ilya_shaikovsky

          in case of nested lists you could use rich:dataTable to iterate over the top level list and rich:collapsibleSubtable(RF 4) or rich:subTable(RF 3) to iterate over sublist.

          • 2. How to iterate a List<List<String>> uisng rich:dataTable component
            sri_kanthu

            thankx Ilya Shaikovsky for your reply!

             

            I have implemented what you suggested,but the desired output is not coming. See the below code image:

             

            code.jpg

             

            here sourceHeaderList in sessionScope contains the following List<List<String>> values:

             

            [[RequestId, Name, Dob,SSN.MRN], [mothername,fatherName,spousename], [Address, HouseNo, City, State, Country, Pincode], [PhoneNo, Fax], [EmailId]]

             

             

            By using the above code I am displaying like below:

             

            subtable.jpg

            As per my observation the subtable contents are displaying vertically but i need all subtables horizontally like below:

             

            table.jpg

             

            how to achieve this?

            • 3. Re: How to iterate a List<List<String>> uisng rich:dataTable component
              ilya_shaikovsky

              at first subtable should be outside of the column. But anyway - leave that approach I was slightly mistaken.

               

              use rich:columns instead of subtable to generate columns dynamically in a row.

              • 4. How to iterate a List<List<String>> uisng rich:dataTable component
                sri_kanthu

                Can you provide with a small example of iterating nested lists using rich:columns.

                 

                i have cahnged the code from rich:subTable to rich:columns like below:

                 

                <h:outputLabel value="Customer Source Demographics:" styleClass="outputLabel_head" />

                        <rich:dataTable value="#{sessionScope.sourceHeaderList}" var="srcHeaderNamesList" >

                            <rich:columns value="#{srcHeaderNamesList}" var="srcHeaderNames">

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

                            </rich:columns>   

                        </rich:dataTable>

                 

                I am getting the below Exception:

                 

                SEVERE: FOREACH_BAD_ITEMS

                javax.servlet.jsp.JspTagException: FOREACH_BAD_ITEMS

                    at org.richfaces.iterator.SimpleForEachIterator.toForEachIterator(SimpleForEachIterator.java:135)

                    at org.richfaces.iterator.SimpleForEachIterator.supportedTypeForEachIterator(SimpleForEachIterator.java:98)

                    at org.richfaces.taglib.ColumnsHandler.prepare(ColumnsHandler.java:304)

                    at org.richfaces.taglib.ColumnsHandler.apply(ColumnsHandler.java:489)

                    at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)

                    at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)

                    at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)

                    at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)

                    at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)

                    at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)

                    at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)

                    at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)

                    at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)

                    at com.sun.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:109)

                    at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)

                    at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)

                    at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)

                • 5. How to iterate a List<List<String>> uisng rich:dataTable component
                  nbelaevski

                  Hi,

                   

                  Does the nested list have fixed size?

                  • 6. How to iterate a List<List<String>> uisng rich:dataTable component
                    sri_kanthu

                    hi,

                     

                    Sorry for late replying I was out of station for couple of days.

                     

                    Nested list does not have fixed size. The size changes dynamically.

                    • 7. How to iterate a List<List<String>> uisng rich:dataTable component
                      nbelaevski

                      Data table is required to have the same number of columns for every row (you can use colspans and rowspans, but that's not the case). Try another iteration component, like data grid with nested repeat.

                      • 8. How to iterate a List<List<String>> uisng rich:dataTable component
                        sri_kanthu

                        hi ,

                        i tried with rich:dataGrid component but the desired output is not coming. See the below code:

                         

                        <rich:dataGrid value="#{sessionScope.sourceHeaderList}" var="srcHeaderNamesList" >

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

                        </rich:dataGrid>

                         

                        When i ran the code the ouput looks like below:

                         

                        result.jpg

                         

                        In the above we can see the dataGrid iterating the subList and displaying the the sublist contents horizontally as a list. If i write another dataGrid inside parent dataGrid the display will be like each vertically separated dataGrid. But my desired output is like the one in above image (as Customer Target Demographics which achieved by using c:forEach and normal HTML Table Element).

                         

                        How can we achieve the above table like display using dataGrid? Am i missing any attribute?

                        • 9. How to iterate a List<List<String>> uisng rich:dataTable component
                          nbelaevski

                          Try with nested repeat instead.

                          • 10. How to iterate a List<List<String>> uisng rich:dataTable component
                            sri_kanthu

                            nested repeat means?

                            • 11. How to iterate a List<List<String>> uisng rich:dataTable component
                              ilya_shaikovsky

                              <a:repeat value="#{bean.parentList}" var="list">

                              <a:repeat value="#{list.innerList}">

                              <!--content-->

                              </a:repeat>

                              </a:repeat>