3 Replies Latest reply on Sep 5, 2012 4:08 AM by hegemondev

    <rich:dataTable> with a static content?

    xmdx

      Hi guys!

      Can I make a rich:dataTable with a static content? I mean without list with data (and of course without var="record" value="#{report.expReport.records}" )

       

      I mean i just need to make an analog of this html code using richfaces:

       

      <table>

         <thead colspan="2">

           <td></td>

         </thead>

         <tr>

           <td></td>

           <td></td>

         </tr>

      </table>

       

      I can't understand why, but I can't do this. Everytime I see just header part.

      That's one of my attempts:

       

      <h:dataTable width="100%" >

          <f:facet name="header">

            <h:column colspan="2">

                  <h:outputText value="Header text" />

            </h:column>

          </f:facet>

       

          <h:column breakBefore="true">

               <h:outputText value="123" />

          </h:column>

          <h:column>

               <h:outputText value="456" />

          </h:column>

       

      </h:dataTable>

       

      Thank for your help!

        • 1. <rich:dataTable> with a static content?
          ilya_shaikovsky

          iteration component will not works without dataModel

           

          So just use html table and apply richfaces rich-* classes listed in documentation.

          1 of 1 people found this helpful
          • 2. <rich:dataTable> with a static content?
            nbelaevski

            You can use value="#{facesContext}" and iterate over those single object. But I'm curious - why use JSF component when all you need is HTML markup?

            • 3. Re: <rich:dataTable> with a static content?
              hegemondev

              The problem is with richFaces. Static tables are not skinned, and look completely different. You have to provide the "look" manually (by applying all kinds of css styles), which is awful.

               

              **The solution is: use rich:dataTable, providing some dummy value** (*rich:dataTable value="DummyStaticValue"*) and use *rich:columnGroup* together with *rich:column*. Your combination will only be rendered once (because of the dummyValue being just a string), and you can get any table structure you want.

               

                        <rich:dataTable width="100%" value="DummyStaticValue">

                                  <f:facet name="header">

                                            <h:outputText value="myHeader" />

                                  </f:facet>

                                  <rich:columnGroup>

                                            <rich:column>

                                                      <h:outputText value="myValue1" />

                                            </rich:column>

                                            <rich:column>

                                                      <h:outputText value="myValue2" />

                                            </rich:column>

                                  </rich:columnGroup>

                                  <rich:columnGroup>

                                            <rich:column>

                                                      <h:outputText value="myValue3" />

                                            </rich:column>

                                            <rich:column>

                                                      <h:outputText value="myValue4" />

                                            </rich:column>

                                  </rich:columnGroup>

                       </rich:dataTable>