0 Replies Latest reply on May 8, 2007 8:09 AM by tobitobsen

    Problem with valueChangeListener in inputText of a DataTable

    tobitobsen

      Hello,
      I write a program which should show Data in a Table and the user should be able to edit them.
      The Table has to be generated dynamicaly. For simplicity I create a table with 2 cols und 2 rows (see: getColumnModel() and getTableModel() in SessionBean). When I run the application there appears a problem.
      The valueChanged - Method is just called when I change the value of one of the two fields in the first column.
      Why isnt the Method called when I change the value of a field of the second column?

      My jsp-File looks as followed:
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>



      Vitax Web 1.0


      <f:view>
      <h:form id="taxForm">
      <t:dataTable id="taxTable" var="row" value="#{taxTable.tableModel}">
      <t:columns value="#{taxTable.columnModel}" var="col">
      <f:facet name="header">
      <h:outputText value="#{col}" />
      </f:facet>
      <t:inputText id="in" value="#{row[taxTable.columnModel.rowIndex]}"
      valueChangeListener="#{taxTable.valueChanged}" immediate="true"
      onchange="submit()">
      </t:inputText>
      </t:columns>
      </t:dataTable>
      </h:form>
      </f:view>



      Here is the code for the taxTable SessionBean:
      public class TaxTable {
      private javax.faces.model.ListDataModel tableModel;
      private javax.faces.model.ListDataModel columnModel;
      public SessionBean() {
      }

      public void valueChanged(ValueChangeEvent evt) {
      System.out.println("Old Value: "+evt.getOldValue().toString());
      System.out.println("New Value: "+evt.getNewValue().toString());
      }



      public javax.faces.model.ListDataModel getTableModel() {
      if(tableModel == null) {
      Object[] o1 = new Object[] {"Zeile 1", new Integer(1)};
      Object[] o2 = new Object[] {"", new Integer(2)};
      List<Object[]> l = new ArrayList<Object[]>();
      l.add(o1);
      l.add(o2);
      tableModel = new ListDataModel(l);
      }
      return tableModel;
      }

      public void setTableModel(javax.faces.model.ListDataModel tableModel) {
      this.tableModel = tableModel;
      }

      public javax.faces.model.ListDataModel getColumnModel() {
      if(columnModel == null) {
      String[] o1 = new String[] {"Spalte1", "Spalte2"};
      List l = new ArrayList();
      l.add(o1[0]);
      l.add(o1[1]);
      columnModel = new ListDataModel(l);
      }
      return columnModel;
      }

      public void setColumnModel(javax.faces.model.ListDataModel columnModel) {
      this.columnModel = columnModel;
      }
      }

      I'm using myfaces1.1.4 (Tomahawk) and apache Tomcat5.5.20.
      Please help me.
      Thx!