1 Reply Latest reply on Jul 12, 2007 11:12 PM by sergeysmirnov

    dataTable and subTable cannot work with a4j:support properly

      Hello,

      I found the problem that a4j:support has problem when the component was embeded into subTable. For the dataTable, it works only when there is no embeded dataTable. If the component was in the dataTable which embeded in another dataTable, the a4j:support can not update the value of the backing bean.

      Here is the example. Could anyone help me out? I guess this is a bug of richfaces's dataTable and subTable components.

      In my cases, I didn't have fixed form bean model , the table content was dynamically contructed.

      // form.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:t="http://myfaces.apache.org/tomahawk"
      xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
      xmlns:rich="http://richfaces.ajax4jsf.org/rich">
      Unique SP id Test


      <f:view>

      ??<h:form>
      <rich:dataTable
      id="chartTable"
      onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
      cellpadding="0" cellspacing="0"
      width="100%" height="100%" border="0"
      var="chartparams"
      value="#{hogeForm.list}">

      <f:facet name="header">
      <rich:columnGroup>
      <rich:column>
      <h:outputText value="Form Ajax Submition Test"/>
      </rich:column>
      </rich:columnGroup>
      </f:facet>

      <rich:column colspan="2">
      <rich:dataTable id="ptable-input"
      onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
      onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
      var="p2" value="#{hogeForm.list}">
      <rich:column styleClass="ptablecolbody">
      <h:outputText styleClass="ptableNameCol" value="#{p2.name}" />
      </rich:column>
      <rich:column styleClass="ptablecolbody">
      <h:inputText name="#{p2.name}" styleClass="ptableValueCol" value="#{p2.value}">
      <a4j:support
      event="onchange"
      action="#{hogeForm.update}"
      ajaxSingle="true"
      immediate="true"
      />
      </h:inputText>
      </rich:column>
      </rich:dataTable>
      </rich:column>
      </rich:dataTable>

      <h:inputText value="#{hogeForm.a}" >
      <a4j:support event="onchange" action="#{hogeForm.doChangeAB}"

      ajaxSingle="true" reRender="a" />
      </h:inputText>


      <h:inputText id="b" value="#{hogeForm.b}" >
      <a4j:support id="bSupport" event="onchange"
      action="#{hogeForm.doChangeAB}"
      ajaxSingle="true" reRender="a" />
      </h:inputText>


      ??</h:form>

      </f:view>



      // Back Bean

      package jsf.beans.test;

      import java.util.*;
      import javax.faces.component.UIComponent;
      import javax.faces.event.ActionEvent;
      import javax.faces.model.SelectItem;

      public class HogeFormBean implements java.io.Serializable{

      private String a =" text ";
      private String b ="";
      private List bList = new ArrayList();

      private List list = new ArrayList();

      private List list2 = new ArrayList();

      /** Creates a new instance of HogeFormBean */
      public HogeFormBean() {
      SelectItem s1 = new SelectItem("1");
      SelectItem s2 = new SelectItem("2");
      bList.add(s1);
      bList.add(s2);

      FakeNV f1 = new FakeNV("n1", "v1");
      FakeNV f2 = new FakeNV("n2", "v2");

      getList().add(f1);
      getList().add(f2);

      FakeNV f3 = new FakeNV("n12", "v12");
      FakeNV f4 = new FakeNV("n22", "v22");
      FakeNV f5 = new FakeNV("n23", "v23");

      getList2().add(f3);
      getList2().add(f4);
      getList2().add(f5);
      }

      public String getA() {
      return a;
      }

      public void setA(String a) {
      this.a = a;
      }

      public String getB() {
      return b;
      }

      public void setB(String b) {
      this.b = b;
      }

      public void doChangeA(){
      System.out.println("do Change A");

      }
      public void doChangeAB() {
      System.out.println(" Current A =" + this.a);
      System.out.println(" Current B =" + this.b);
      }

      public void doChangeA(ActionEvent event){

      UIComponent ui = (UIComponent) event.getSource();

      System.out.println(" Current A =" + this.a);

      }

      public void doChangeB() {
      System.out.println("do Change B");
      }

      public List getBList() {
      return bList;
      }

      public void setBList(List bList) {
      this.bList = bList;
      }

      public List getList() {
      return list;
      }

      public void setList(List list) {
      this.list = list;
      }

      public void update(){
      for(FakeNV nv : list){
      System.out.println(nv.getName() +" = " + nv.getValue());
      }
      for(FakeNV nv : list2){
      System.out.println(nv.getName() +" = " + nv.getValue());
      }
      }

      public List getList2() {
      return list2;
      }

      public void setList2(List list2) {
      this.list2 = list2;
      }
      }

      //faces-config.xml

      <managed-bean>
      <managed-bean-name>hogeForm</managed-bean-name>
      <managed-bean-class>jsf.beans.test.HogeFormBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>

      ======================