Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12274

Datatable (rich:dataTable) is not populated with data

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 4.2.1.Final
    • Fix Version/s: None
    • Component/s: component-tables
    • Environment:

      Windows 7 64bit
      Tomcat 7.0.26
      myfaces-core-2.0.13
      richfaces 4.2.1
      JRE 6
      MySQL Server 5.5
      mysql-connector-java-5.1.18

      Description

      Hello,

      When I use the following BeanClass and XHTML page, Datatable is not populated with data, despite the method getAll() returns ResultSet that contains customer names.
      To demonstrate this, I've added a line System.out.println(crs.getString("Name")) that iterates through the ResultSet and prints customer names from customer table before the ResultSet is being returned to t:dataTable component.
      It's important to mention, that once I change <rich:datatable> to <h:datatable>, I do get the populated rows in the table.

      This is Tomcat log that ilustrates that the resultset contains data:

      "Tomcat Log"
      29/03/2012 22:19:57 org.apache.coyote.AbstractProtocol start 
      INFO: Starting ProtocolHandler ["http-bio-8080"] 
      29/03/2012 22:19:57 org.apache.coyote.AbstractProtocol start 
      INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
      29/03/2012 22:19:57 org.apache.catalina.startup.Catalina start 
      INFO: Server startup in 4706 ms 
      29/03/2012 22:19:58 org.apache.myfaces.util.ExternalSpecifications isUnifiedELAvailable 
      INFO: MyFaces Unified EL support enabled 
      
      Start of Debug 
      
      William Dupont 
      William Dupont 
      
      End of Debug 
      

      This is the ManagedBean:

      "ManagedBean"
      package com.corejsf; 
      
      import java.sql.Connection; 
      import java.sql.ResultSet; 
      import java.sql.SQLException; 
      import java.sql.Statement; 
      import javax.annotation.Resource; 
      import javax.faces.bean.*; 
      import javax.sql.DataSource; 
      import javax.sql.rowset.CachedRowSet; 
      
      
      @ManagedBean 
      @RequestScoped 
      
      public class CustomerBean { 
      
      @Resource(name="jdbc/Sufa") private DataSource ds; 
      
          public ResultSet getAll() throws SQLException { 
              
            Connection conn = ds.getConnection(); 
      try { 
                
              Statement stmt = conn.createStatement(); 
              ResultSet result = stmt.executeQuery("SELECT * FROM customers"); 
              CachedRowSet crs = new com.sun.rowset.CachedRowSetImpl(); 
              crs.populate(result); 
                
              System.out.println("Start of Debug"); 
                
              while(crs.next()) { 
                System.out.println(crs.getString("Name")); 
      } 
                
              System.out.println("End of Debug"); 
      
              return crs; 
                
            } finally { 
      conn.close(); 
            } 
          } 
      } 
      

      This is xhtml page:

      "Facelet page"
      <?xml version="1.0" encoding="UTF-8"?> 
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
      <html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:rich="http://richfaces.org/rich"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 
      <h:body> 
      <h:form> 
      
      <rich:dataTable value="#{customerBean.all}" var="customer"> 
        <rich:column> 
          <f:facet name="header">#{msgs.nameHeader}</f:facet> 
            #{customer.Name} 
        </rich:column> 
      </rich:dataTable> 
      
      </h:form> 
      </h:body> 
      </html> 
      

      Thanks a lot

      Sagi

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                bleathem Brian Leathem
                Reporter:
                kovaliovsg Sagi Kovaliov
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: