2 Replies Latest reply on Jun 29, 2011 7:26 AM by jayesh_rhds

    Problem in displaying data in Richface DataTable

    jayesh_rhds

      Hi,

       

      I am stucked with datatable. I am using this on jsp page:

       

      <h:dataTable value="#{AList.myArr}" var="capt"  border="1" 
                      headerClass="header"   rowClasses="row1,row2">
                          <h:column >
                              <f:facet name="header" > <f:verbatim>State</f:verbatim> </f:facet>
                              <h:outputText value="#{capt}" />
                          </h:column>
      </h:dataTable>
      

       

      i am using arraylist to store some data in a bean Alist:

       

      package demo;
      
      import java.util.*;
      import java.io.*; 
      
      
      public class Alist {
                ArrayList<String> myArr = new ArrayList<String>(10);
                public Alist() 
                { 
          myArr.add("Italian Riviera");
          myArr.add("Jersey Shore");
          myArr.add("Puerto Rico");
          myArr.add("Los Cabos Corridor");
          myArr.add("Lubmin");
          myArr.add("Coney Island");
          myArr.add("Karlovy Vary");
          myArr.add("Bourbon-l'Archambault");
          myArr.add("Walt Disney World Resort");
          myArr.add("Barbados");
                }
                public ArrayList<String> getMyArr() {
                          return myArr;
                }
                public void setMyArr(ArrayList<String> myArr) {
                          this.myArr = myArr;
                }
      }
      

       

      I am using Richfaces 4 Final in JBoss Dev Studio 4 GA using JBoss 6 server.

      The display page only displays the header and no data from the arraylist. Kindly help me...

        • 1. Re: Problem in displaying data in Richface DataTable
          mp911de

          Hi Jayesh,

          have you defined your Class as Managed Bean? (JSF 1.x: faces-config.xml, JSF 2.0: @ManagedBean, @SessionScoped (for example) annotations in your Class).

           

          Best regards,

          Mark

          • 2. Re: Problem in displaying data in Richface DataTable
            jayesh_rhds

            Hi,

             

            A very strange thing happenned. Yesterday the whole day i was tried to run it by changing codes, face-config, republishing etc but it didn't run. Today the first thing i did was open up the app and run it and there it was, running very well, displaying all the data. earlier whne i changed the static content, it did reflect in the web page, so publishing was working.

             

            Anyhow now i have to implement sorting but the moment i click in the sort header, nothing happens except that the URL is appended by a # sign. Here is the sorting class which i have defined:

            package demo;
            import org.richfaces.component.SortOrder;
            import javax.faces.bean.ManagedBean;
            import javax.faces.bean.ViewScoped;
            import javax.faces.bean.SessionScoped;
            
            @ManagedBean
            @ViewScoped
            @SessionScoped
            public class sorting {
                      private SortOrder capSort = SortOrder.unsorted;
            
                      public void sortByCaps(){
                                if (capSort.equals(SortOrder.ascending)) {
                        setCapSort(SortOrder.descending);
                    } else {
                        setCapSort(SortOrder.ascending);
                    }
                      }
            
                      public SortOrder getCapSort() {
                                return capSort;
                      }
            
                      public void setCapSort(SortOrder capSort) {
                                this.capSort = capSort;
                      }
            }
            
            

            And the modified xhtml page is as below:

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
                <h:form>
                    <rich:dataTable value="#{AList.myArr}" var="capt" id="table">
                        <rich:column sortBy="#{capt}" id="name" sortOrder="#{Sort.capSort}">
                            <f:facet name="header">
                                <a4j:commandLink value="Sort by Name" render="table"
                                    action="#{Sort.sortByCaps}" />
                            </f:facet>
                            <h:outputText value="#{capt}" />
                        </rich:column>
                    </rich:dataTable>
                </h:form>
            </ui:composition>
            

            Kindly help me with this...

             

            Edit Note: In IE, I am getting a warning error on bottom-left of the browser which on clicking displays 'RichFaces' is undefined. Its a warning error though.