4 Replies Latest reply on Dec 1, 2011 6:43 AM by stianst

    rich:dataTable value called when not required with a4j:poll

    stianst

      I have a problem where parts of my beans are invoked by an a4j:poll even though they shouldn't be as they aren't specified in the render attribute. I've found out that this is caused by rich:dataTable being processed even though it shouldn't. If I switch to h:dataTable everything works fine.

       

      My test view looks like this:

       

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        
      <html xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
      <h:head>
      </h:head>
      <h:body>
                  <h:form>
                          <a4j:poll id="ajaxChecker" render="ajaxCount" interval="1000" />
                </h:form>
                  <rich:dataTable var="c" value="#{ajax.ajaxCount}" id="ajaxCount">
                          <h:column>
                                    <h:outputText value="#{c}" />
                          </h:column>
                </rich:dataTable>
                  <rich:dataTable var="c" value="#{ajax.count}" id="count">
                          <h:column>
                                    <h:outputText value="#{c}" />
                          </h:column>
                </rich:dataTable>
      </h:body>
      </html>
      

       

      and the bean is:

       

      @Named
      @SessionScoped
      public class Ajax implements Serializable
      {
          private static final long serialVersionUID = 1L;
          private volatile int ajaxCount = 0;
          private volatile int count = 0;
      
          public List<Integer> getAjaxCount()
          {
              System.out.println("getAjaxCount");
              return Collections.singletonList(ajaxCount++);
          }
      
          public boolean isEvent()
          {
              return ajaxCount % 10 == 0;
          }
      
          public List<Integer>  getCount()
          {
              System.out.println("getCount");
              return Collections.singletonList(count++);
          }
      }
      

       

      From the output on the server I can see that getAjaxCount is called twice and getCount once every second. I'm expecting getAjaxCount to be invoked once every second, and getCount to only be invoked when the page is refreshed.

       

      It seems to me that this is caused by a bug in rich:dataTable?