3 Replies Latest reply on Jun 18, 2007 10:39 AM by Michael Haug

    a4j:commandButton does not rerender rich:datatable

    Michael Haug Newbie

      after migration to JSF 1.2 (from myfaces 1.1.5) rerendering of rich:datatable is broken. Since rerendering of the standard datatable is still
      working, it seems there is something wrong in rich:datatable.

      I used the following environment for the test:

      - Apache Tomcat 6.0.13
      - JSF 1.2 RI (jsf-1.2_04-b10-p01)
      - Richfaces 3.0.2-SNAPSHOT
      - ajax4jsf 1.1.2-SNAPSHOT

      The following test case proofs that the standard datatable rerenders as expected if the command button is clicked but rich:datatable is empty...

      Test.jsp:

      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
      <html>
      <head>
      <title>Demo</title>
      </head>
      <body>
      <f:view>
      <h:form>
       <a4j:commandButton action="#{finderResult.search}" reRender="table1, table2" value="Search"/>
      
       <rich:dataTable id="table1" var="tableRow" value="#{finderResult.allItems}">
       <h:column>
       <f:facet name="header">
       <h:outputText value="Name"/>
       </f:facet>
       <h:outputText value="#{tableRow.name}"/>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Description"/>
       </f:facet>
       <h:outputText value="#{tableRow.description}"/>
       </h:column>
       </rich:dataTable>
      
       <h:dataTable id="table2" var="tableRow" value="#{finderResult.allItems}">
       <h:column>
       <f:facet name="header">
       <h:outputText value="Name"/>
       </f:facet>
       <h:outputText value="#{tableRow.name}"/>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Description"/>
       </f:facet>
       <h:outputText value="#{tableRow.description}"/>
       </h:column>
       </h:dataTable>
      </h:form>
      </f:view>
      </body>
      </html>


      FinderResult.java:
      package demo;
      
      import java.util.ArrayList;
      import java.util.List;
      
      public class FinderResult
      {
       private List allItems = new ArrayList();
      
       public void search()
       {
       allItems = new ArrayList();
       for (int i = 1; i <= 20; i++)
       {
       FinderResultItem item = new FinderResultItem();
       item.setName("Name" + i);
       item.setDescription("Description" + i);
       allItems.add(item);
       }
       }
      
       public List getAllItems()
       {
       return allItems;
       }
      }


      FinderResultItem.java:
      package demo;
      
      import java.io.Serializable;
      
      public class FinderResultItem implements Serializable
      {
       private String name;
       private String description;
      
       public String getName()
       {
       return name;
       }
       public void setName(String name)
       {
       this.name = name;
       }
       public String getDescription()
       {
       return description;
       }
       public void setDescription(String description)
       {
       this.description = description;
       }
      }


      faces-config.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <faces-config
       xmlns="http://java.sun.com/xml/ns/javaee"
       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"
       version="1.2">
      
       <managed-bean>
       <managed-bean-name>finderResult</managed-bean-name>
       <managed-bean-class>demo.FinderResult</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" id="WebApp_ID" version="2.5">
      
       <display-name>Demo</display-name>
       <context-param>
       <param-name>org.ajax4jsf.SKIN</param-name>
       <param-value>blueSky</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>
       </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>/faces/*</url-pattern>
       </servlet-mapping>
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       <welcome-file>index.htm</welcome-file>
       <welcome-file>index.jsp</welcome-file>
       <welcome-file>default.html</welcome-file>
       <welcome-file>default.htm</welcome-file>
       <welcome-file>default.jsp</welcome-file>
       </welcome-file-list>
      
      </web-app>


      kind regards
      Michael