7 Replies Latest reply on Mar 12, 2009 8:52 AM by marian furdui

    need help with rich:dataTable!

    marian furdui Newbie

      Hi!
      I am struggling for few days with this and nothing so far:
      I try to display a simple rich:dataTable, but only the table header is shown and no rows.

      The sample on which I am working is based on first part of this article:
      http://java.dzone.com/articles/an-introduction-to-jboss-richf?page=0,0.

      Some other rich faces like menus and menu items are working.
      But this one does not and there is no output to show what is missing or wrong :(
      I have:

      Eclipse 3.4
      JBoss 5.0.1
      RichFaces 3.3.0-GA


      What is missing? What is wrong?

      Any help would be appreciated!
      Thanks in advance!

      Below are the files and configurations:

      User.java


      public class User {
      
       @Override
       public String toString() {
       return name + " " + email;
       }
      
       private String name;
       private String email;
      
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       public String getEmail() {
       return email;
       }
      
       public void setEmail(String email) {
       this.email = email;
       }
      
       public User(String name, String email) {
       super();
       this.name = name;
       this.email = email;
       }
      }


      UserBean.java

      import java.util.ArrayList;
      import java.util.List;
      import javax.annotation.PostConstruct;
      
      public class UserBean {
      
       private List<User> users;
      
       public List<User> getUsers() {
       return users;
       }
      
       @PostConstruct
       public void init() {
      
       users = new ArrayList<User>();
       users.add(new User("Joe", "joe@gmail.com"));
       users.add(new User("Charley", "charley@ymail.com"));
       users.add(new User("John", "john@hotmail.com"));
       users.add(new User("Greg", "greg@gmail.com"));
       users.add(new User("Prescila", "prescila@aol.com"));
      
       }
      }
      


      faces-config.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
       <application>
       <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
       </application>
       <managed-bean>
       <description>userBean</description>
       <managed-bean-name>userBean</managed-bean-name>
       <managed-bean-class>test.beans.UserBean</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
       </managed-bean>
      </faces-config>
      


      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       version="2.5">
       <description>Sample application</description>
       <display-name>Sample application</display-name>
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
       <context-param>
       <param-name>facelets.REFRESH_PERIOD</param-name>
       <param-value>2</param-value>
       </context-param>
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
       </context-param>
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>ruby</param-value>
       </context-param>
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       <dispatcher>ERROR</dispatcher>
       </filter-mapping>
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>/test/*</url-pattern>
       </servlet-mapping>
       <login-config>
       <auth-method>BASIC</auth-method>
       </login-config>
      </web-app>


      test.xhtml

      <!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: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">
      <head>
      <title><ui:insert name="title" /></title>
      </head>
      <body>
      <ui:include src="users.xhtml" />
      </body>
      </html>


      users.xhtml

      <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">
      
       <rich:panel>
       <f:facet name="header">
       Just some users
       </f:facet>
      
       <rich:dataTable value="#{userBean.users}" var="user">
      
       <h:column>
       <h:outputText id="name" value="#{user.name}" />
       </h:column>
       <h:column>
       <h:outputText id="email" value="#{user.email}" />
       </h:column>
      
       </rich:dataTable>
       </rich:panel>
       <a4j:keepAlive beanName="userBean"></a4j:keepAlive>
      </ui:composition>