4 Replies Latest reply on Nov 8, 2010 4:39 AM by Joeri Hendrickx

    Rich:subtable renders incorrectly

    Joeri Hendrickx Newbie

      Hello,

       

      I'm trying to make rich:subtable work, but I can't find a decent example anywhere.

       

      I started with a really simple dummy page, but even that won't work.

       

      Here's the code for the table:

               <rich:dataTable value="#{test.simpleItems}" var="item">
                      <rich:column>
                          <h:outputText value="#{item.name}" />            
                      </rich:column>
                      <rich:column>
                          <h:outputText value="#{item.capital}" />            
                      </rich:column>
                      <rich:column>
                          <h:outputText value="#{item.density}" />            
                      </rich:column>
                      <rich:subTable value="#{item.people}" var="person">
                          <rich:column>
                              <h:outputText value="#{person.name}" />
                          </rich:column>
                          <rich:column>
                              <h:outputText value="#{person.birth}" />
                          </rich:column>
                          <rich:column>
                              <h:outputText value="#{person.death}" />
                          </rich:column>
                      </rich:subTable>
                  </rich:dataTable>
      

       

      should be really simple.  I made four example countries, and put in some random known people.

       

      The output however, is like this:

       

      BelgiumBrussels26562
      Georges Remi19071983
      Eddy Merckx1945
      FranceParis13500
      Antoine de Saint-Exupery19001944
      Napoleon Bonaparte17691821
      Claude Debussy18621918
      GermanyBerlin61632
      The NetherlandsAmsterdam12
      Vincent van Gogh18531890

       

      (data is fake, obviously)

       

      I tried playing with rowspan and colspan, and it does move stuff around, but I found no way to actually make it behave like it should.

       

      What am I doing wrong?

       

      Regards,

      Joeri

       

       

       


        • 1. Re: Rich:subtable renders incorrectly
          Nick Belaevski Master

          Hi Joeri,

           

          Output looks just fine, can you please provide more information on what you are expecting to get?

          • 2. Re: Rich:subtable renders incorrectly
            Joeri Hendrickx Newbie

            Hi Nick,

             

            I would have expected something more like this:

             

            BelgiumBrussels26562Georges Remi19071983
            Eddy Merckx
            FranceParis13500Antoine de Saint-Exupery19001944
            Napolean Bonaparte17691821
            Claude Debussy18621918
            GermanyBerlin61632
            The NetherlandsAmsterdam12Vincent Van Gogh18531890

             

            Since the subtable comes instead of a column, this would make most sense to me.

            • 3. Re: Rich:subtable renders incorrectly
              Ilya Shaikovsky Master

              actually subtable work just as designed. It shows details table below the master row.

               

              Some time ago I created a workaround. It works with two level's of nesting but has problems if more. So if you have only two levels - you could try. http://community.jboss.org/message/541778#541778

              • 4. Re: Rich:subtable renders incorrectly
                Joeri Hendrickx Newbie

                Thanks Ilya,

                 

                Yeah it seems like I misunderstood what subtable is actually supposed to do.  The example on the richfaces website only shows a table with a subtable and no other columns, so it's not really clear what the subtable is for.

                 

                Anyway, in case anyone bumps into this: I found a way to make it do what I want it to do, but I don't guarantee anything

                 

                 

                <rich:dataTable value="#{test.countries}" var="country">
                  <rich:column rowspan="#{country.people.size() + 1}">
                    <h:outputText value="#{country.name}" />            
                  </rich:column>
                  <rich:column rowspan="#{country.people.size() + 1}">
                    <h:outputText value="#{country.capital}" />            
                  </rich:column>
                  <rich:column rowspan="#{country.people.size() + 1}">
                    <h:outputText value="#{country.density}" />            
                  </rich:column>
                  <rich:subTable value="#{country.people}" var="person">
                    <rich:column>
                      <h:outputText value="#{person.name}" />
                    </rich:column>
                    <rich:column>
                      <h:outputText value="#{person.birth}" />
                    </rich:column>
                    <rich:column>
                      <h:outputText value="#{person.death}" />
                    </rich:column>
                  </rich:subTable>
                </rich:dataTable>
                

                 

                I know, the +1 doesn't make any sense.  Even the html output doesn't make any sense to me (the browser displays two trs next to each other) but it does render the way I want on firefox and IE.

                 

                Pretty hacky though