6 Replies Latest reply on Feb 22, 2011 7:32 PM by psramkumar.ps.ramkumar.gmail.com

    rich:columns are not rendering anything.(Dynamic columns are not working with datatable and extendedDataTable.

      Hi All,


      Have anybody tried dynamic columns (rich:columns) with seam.
      I tried but it renders nothing.If i use rich:column it renders
      all data.


      Can anybody tell me how i can overcome from this issue?


      Its too urgent.


      Thanks a lot in advance.


      Please forward your ideas to me.


      Regards,
      Manish

        • 1. Re: rich:columns are not rendering anything.(Dynamic columns are not working with datatable and extendedDataTable.
          gonorrhea

          1) if it's too urgent then post your code
          2) this topic belongs on the RF forum
          3) have you tried something like this?


          <ui:composition xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich">
              <h:form>
                  <rich:dataTable value="#{dataTableScrollerBean.model}" var="model" width="750">
          
                      <f:facet name="header">
                          <h:outputText value="Cars Available"></h:outputText>
                      </f:facet>
                      
                      <rich:columns value="#{dataTableScrollerBean.columns}" var="columns"
                          index="ind" sortBy="#{model[ind].price}">
                           
                          <f:facet name="header">
                              <h:outputText value="#{columns.header}" />
                          </f:facet>
                      
                          <h:outputText value="#{model[ind].model} " />
                          <h:outputText value="#{model[ind].mileage} miles " />
                          <h:outputText value="#{model[ind].price}$"
                              style="font-style:italic;" />
                              
                      </rich:columns>
                      
                  </rich:dataTable>
              </h:form>
          </ui:composition>



          It's not using extendedDataTable component, but give it a try.  This code is from the RichFaces Live Demo site.

          • 2. Re: rich:columns are not rendering anything.(Dynamic columns are not working with datatable and extendedDataTable.
            Thanks a lot Arbi Sookazian.

            Following is my test.xhtml file :

            <ui:define name="main">
            <f:facet name="header">Test Data Table</f:facet>
            <rich:panel><f:facet name="header">Data Table </f:facet>
            <h:form>
               <rich:dataTable value="#{rowList}" var="tableObj" width="750">
               <f:facet name="header">
               <h:outputText value="Rules"></h:outputText>
               </f:facet>
               <rich:columns value="#{columnList}" var="colm"> 
                  <f:facet name="header">
                     <h:outputText value="#{colm.header}"/>
                  </f:facet>
                  <h:outputText value="#{tableObj[0]}"/>
               </rich:columns>
               </rich:dataTable>
                </h:form>
               </rich:panel>
              </ui:define>
            Following is my backing bean :

            @Stateless
            @Name("testManager")
            @Scope(ScopeType.SESSION)
            public class TestManagerBean implements TestManager   {        
            @Logger private Log log;        
            @In FacesMessages facesMessages; 
            @DataModel(scope = ScopeType.PAGE)
            List<Object[]> rowList;
            @DataModel(scope = ScopeType.PAGE)
            List<Column> columnList;

            @Factory("columnList")
            public void populateColumnList(){
               columnList=new ArrayList<Column>();
               columnList.add(new Column("First-Name"));
               columnList.add(new Column("Middle-Name"));
               columnList.add(new Column("Last-Name"));     
            }
            @Factory("rowList")   
            public void populateRowList()
            {         
              rowList = new ArrayList<Object[]>(); 
              Object[] names1=new Object[] {"Test1,Test2,Test3"};
              Object[] names2=new Object[] {"Test4,Test5,Test6"};
              rowList.add(names1);
              rowList.add(names2);
            }                    
            @Remove
            public void remove() {
            // TODO Auto-generated method stub          
            }     

            My Column.java

            public class Column {
               private String header;
              
               public Column(String header){
                 this.header=header;
               }
               public String getHeader(){
                  return header;
               }
             
               public void setHeader(String header){
                 this.header=header;
               }

            }

            My datatable is not displayed (or you can say its displying empty datatable).

            I suspect following reason because if i use rich:column it works fine:
            The  <rich:columns>  tag is initialized during components tree building process.
            This process precedes page rendering at "Render Response" JSF phase.

            Please tell me what 's wrong here.

            Thanks a lot in advance.

            Regards,
            Manish


            • 3. Re: rich:columns are not rendering anything.(Dynamic columns are not working with datatable and extendedDataTable.
              swd847

              @DataModel does not work with rich:column. You have to do it like:


              @Factory(value="columnList",scope=PAGE)
              public List<Column> populateColumnList(){
                 List<Column> columnList=new ArrayList<Column>();
                 columnList.add(new Column("First-Name"));
                 columnList.add(new Column("Middle-Name"));
                 columnList.add(new Column("Last-Name"));
                 return columnList;
              }
              
              



              and get rid of


              @DataModel(scope = ScopeType.PAGE)
              List<Column> columnList;
              



              then it will work

              • 4. Re: rich:columns are not rendering anything.(Dynamic columns are not working with datatable and extendedDataTable.

                Thanks a lot Stuart Douglas,


                Your solution has worked for me.
                By mistake i rate 3 stars but you deserve more than 5 stars because you solution has helped me in very critical time.
                I was almost tired by applying different ways.


                Thanks a lot again.


                Regards,
                Manish


                • 5. Re: rich:columns are not rendering anything.(Dynamic columns are not working with datatable and extendedDataTable.
                  new


                  Hi


                  first thank you for this example ı tried it and works fine but my problem is  this datatable initialize when page render but ı want datatable initialize when click a button but it didnt work


                  how can ı do this



                  Thanks in advance.


                  rgd




                  • 6. Re: rich:columns are not rendering anything.(Dynamic columns are not working with datatable and extendedDataTable.
                    psramkumar.ps.ramkumar.gmail.com

                    My Link


                    the same way try this im trying to print the single value in a col...