5 Replies Latest reply on Feb 17, 2011 12:35 PM by Thomas Buckley

    extendedDataTable groupingColumn

    D DG Newbie

      Hello,

       

      By default, extendedDataTable groups are expanded when using a groupingColumn.

       

      Is there a way to have groups rendered collapsed instead?

       

      (Example of my usage below.)

       

      Thanks!

      --ddg

       

      ...

      <rich:extendedDataTable value="#{reservationCart.avbGear}" id="availableGear" var="gear"
                                                          width="650px" groupingColumn="styleSummary" enableContextMenu="false" selectionMode="none">

      ...

      <rich:column sortBy="#{gear.storeSku.sku.style.summary}" width="100px" label="Style" id="styleSummary" visible="false">
                                          <f:facet name="header">
                                              <h:outputText value="Style" />
                                          </f:facet>
                                          <h:outputText value="#{gear.storeSku.sku.style.summary}" />
                                      </rich:column>

      ...

        • 1. Re: extendedDataTable groupingColumn
          Ilya Shaikovsky Master

          no unfortunatelly this feature is not reviewed and improved for such customization and works as it was contributed.

          1 of 1 people found this helpful
          • 2. extendedDataTable groupingColumn
            Thomas Buckley Newbie

            Hi

             

            My first post on the site! Relatively new to Richfaces.

             

            I was wondering is there any way to extend the extendedDataTable base class to implement this feature?

            It's actually a vital requirement of a feature I need to implement.

             

            Thanks

            • 3. extendedDataTable groupingColumn
              Nick Belaevski Master

              Hi Thomas,

               

              Try overriding this method: org.richfaces.component.UIExtendedDataTable.groupIsExpanded(int) or this: org.richfaces.component.UIExtendedDataTable.getState()

              • 4. Re: extendedDataTable groupingColumn
                Thomas Buckley Newbie

                Thanks Nick.

                 

                Now to a more fundamental question

                As I stated in my previous post, I'm new to JSF and Richfaces.

                 

                Would you be able to provide an example of an to override a component method (All steps and files required)?

                Maybe for some simple component method you have done this on? (Doesnt have to be the extendedDataTable).

                 

                I cant seem to find any end-to-end simple example that shows how to overide an existing Richfaces component.

                 

                Appreciate your help.

                • 5. Re: extendedDataTable groupingColumn
                  Thomas Buckley Newbie

                  I've been trying to figure out how to do this and have the following so far:

                   

                  I've created a custom ExtendedDataTableRenderer renderer as follows:

                   

                  package com.test;

                   

                  import java.io.IOException;

                   

                  import javax.faces.component.UIComponent;

                  import javax.faces.context.FacesContext;

                  import org.richfaces.renderkit.html.ExtendedDataTableRenderer;

                   

                  public class HtmlExtendedDataTableRendered extends ExtendedDataTableRenderer

                  {

                            @Override

                            public void encodeBegin(FacesContext context, UIComponent component) throws IOException

                            {

                                      System.out.println("------- in HtmlExtendedDataTableRendered init() -----");

                   

                                      // TODO Auto-generated method stub

                                      super.encodeBegin(context, component);

                            }

                  }

                   

                  And added the following to my faces-config.xml as follows:

                   

                  <render-kit>

                       <renderer>

                            <component-family>org.richfaces.ExtendedDataTable</component-family>

                            <renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>

                            <renderer-class>com.test.HtmlExtendedDataTableRendered</renderer-class>

                       </renderer>

                  </render-kit>

                   

                   

                  When I hit a page that has an entendedDataTable component this seems to be working (It is prining the test code to the console).

                   

                   

                  Now I also extended the HtmlExtendedDataTable class as follows:

                   

                  package com.test;

                   

                  import java.io.IOException;

                  import javax.faces.context.FacesContext;

                  import org.richfaces.component.html.HtmlExtendedDataTable;

                   

                  public class customExtendedDataTable extends HtmlExtendedDataTable {

                      /*

                       * The renderer type for this component.

                      */

                      public static final String RENDERER_TYPE = "com.test.HtmlExtendedDataTableRendered";

                   

                      public customExtendedDataTable() {

                   

                           System.out.println("------- in customExtendedDataTable init() -----");

                   

                           setRendererType(RENDERER_TYPE);

                      }

                   

                     @Override

                      public String getFamily() {

                          return customExtendedDataTable.RENDERER_TYPE;

                      }

                   

                   

                     @Override

                     public boolean groupIsExpanded(int index)

                     {

                          System.out.println("------- in groupIsExpanded -----");

                   

                          // TODO Auto-generated method stub

                          return super.groupIsExpanded(1);

                     }

                   

                     @Override

                     public void encodeBegin(FacesContext context) throws IOException

                     {

                          System.out.println("------- in encodeBegin -----");

                   

                          // TODO Auto-generated method stub

                          super.encodeBegin(context);

                     }

                  }

                   

                   

                   

                   

                  Nothing is been printed to the console from within this class when I enter a page that has the extendedDataTable component.

                   

                  Could you provide me with some help as to why this is not working please?

                   

                  Thanks