1 Reply Latest reply on May 13, 2009 6:24 AM by ilya_shaikovsky

    The value provider of rich:dataTable is called even when reR

    alibsd

      Hi,

      I think there is a strange behavior in rich:dataTable. If a component sends an AJAX
      request with its ajaxSingle="true", and its reRender points to other components than
      rich:dataTable, dataTable gets the value of its ValueExpression. This is a different behavior
      than other components like h:inputText or normal components.

      I run the code below with RichFaces 3.3.0.GA, MyFaces 1.2.6 and Facelets 1.1.14.
      Does anybody know why dataTable has to gets its data, while it is not supposed to
      be rendered?

      Each time "inc" button is clicked, numClicked is increased on the server side, and the
      getter method of h:inputText (with id="name") is not called because "inc" command
      sends single an ajax request and reRenders just outputText, But #{bean.names} is
      called (in Render Response Phase), even though ajaxSingle=true and reRender does not
      point to the id of dataTable.

      Bean.java (Session-Scoped Backing Bean):

      package com.sg;
      
      import java.util.ArrayList;
      import java.util.List;
      
      public class Bean {
       private String name = "Ali";
       private int numClicked = 0;
       private List<String> names;
      
       public Bean() {
       names = new ArrayList<String>();
       names.add("Name 1");
       names.add("Name 2");
       names.add("Name 3");
       names.add("Name 4");
       names.add("Name 5");
       names.add("Name 6");
       names.add("Name 7");
       }
      
       public void incNumClicked() {
       System.out.println("IN INC Command Clicked");
       numClicked++;
       }
      
       public String getName() {
       System.err.println("IN GET NAME");
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       public int getNumClicked() {
       System.err.println("GET NUM CLICKED");
       return numClicked;
       }
      
       public void setNumClicked(int numClicked) {
       this.numClicked = numClicked;
       }
      
       public List<String> getNames() {
       System.err.println("IN GET NAMES");
       return names;
       }
      }
      


      grid.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:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
      <body>
      <f:view>
       <h:form id="form1">
       <h:inputText id="name" value="#{bean.name}" />
       <h:outputText id="clicks" value="You have clicked buttons #{bean.numClicked} times" />
       <a4j:commandButton id="inc" value="button" action="#{bean.incNumClicked}" ajaxSingle="true" reRender="clicks" />
      
       <rich:dataTable value="#{bean.names}" var="name" id="ordersList" rowKeyVar="idx">
       <f:facet name="header">
       <h:outputText value="Orders Table" />
       </f:facet>
      
       <rich:column>
       <h:outputText value="#{idx + 1}" id="idx" />
       </rich:column>
      
       <rich:column>
       <h:outputText value="#{name}" id="name" />
       </rich:column>
       </rich:dataTable>
       </h:form>
      </f:view>
      </body>
      </html>
      


      I hope I could explain the problem. BTW if it is not a bug, how can I prevent dataTable
      from calling #{bean.names}.

      Regards