You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Sagi Kovaliov (JIRA)" <de...@myfaces.apache.org> on 2012/04/21 19:30:34 UTC

[jira] [Created] (TOMAHAWK-1624) Datatable (t:dataTable) is not populated with data

Sagi Kovaliov created TOMAHAWK-1624:
---------------------------------------

             Summary: Datatable (t:dataTable) is not populated with data
                 Key: TOMAHAWK-1624
                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1624
             Project: MyFaces Tomahawk
          Issue Type: Bug
          Components: Extended Datatable
    Affects Versions: 1.1.11
         Environment: Windows 7 64bit 
Tomcat 7.0.26 
myfaces-core-2.0.13
tomahawk20-1.1.11 
JRE 6 
MySQL 5.5 
mysql-connector-java-5.1.18
            Reporter: Sagi Kovaliov


Hello, this bug is simmilar to MYFACES-3518 (https://issues.apache.org/jira/browse/MYFACES-3518).
This bug was related to myfaces core jsf and was fixed in releases 2.0.13 and 2.1.7.
Seems it needs to be fixed in tomahawk Component Set as well.

Here is the description:

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. 
Code line System.out.println(crs.getString("Name")) iterates through the ResultSet and prints customer names from customer table before the ResultSet is being returned to t:dataTable component. This is what I get in Tomcat log: 

.......... 

******************************************************************* 
*** WARNING: Apache MyFaces-2 is running in DEVELOPMENT mode. *** 
*** ^^^^^^^^^^^ *** 
*** Do NOT deploy to your live server(s) without changing this. *** 
*** See Application#getProjectStage() for more information. *** 
******************************************************************* 

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: 

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: 

<?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:t="http://myfaces.apache.org/tomahawk"
xmlns:ui="http://java.sun.com/jsf/facelets"> 
<h:body> 
<h:form> 

<t:dataTable value="#{customerBean.all}" var="customer"> 
  <h:column> 
    <f:facet name="header">#{msgs.nameHeader}</f:facet> 
      #{customer.Name} 
  </h:column> 
</t:dataTable> 

</h:form> 
</h:body> 
</html> 

It's important to mention that the same code works perfect when I change namespace prefix of datatable from "t:" to "h:"  

Thanks a lot 

Sagi 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira