1 2 Previous Next 18 Replies Latest reply on Jan 23, 2009 1:51 PM by Stan Silvert

    How to access cell of

    Wolfgang Knauf Master

      Hi,

      I have a "h:dataTable" and want to loop over it to find a specific item.
      The table contains four columns: ID ("h:outputText"), a "h:outputText" field with id = "name", and two forms (one with an edit link, the other with a delete link).

      I loop over the table and compare the "name" values:

      HtmlDataTable table = (HtmlDataTable) this.server.findComponent("mytable");
      for (int iRow = 0; iRow < table.getRowCount(); iRow++)
      {
       Object objName = this.server.getComponentValue("mytable:" + iRow + ":name");
      }


      This returns "NULL".

      Now, I add this:
      HtmlDataTable table = (HtmlDataTable) this.server.findComponent("mytable");
      for (int iRow = 0; iRow < table.getRowCount(); iRow++)
      {
       table.setRowIndex(iRow);
       Object objName = this.server.getComponentValue("mytable:" + iRow + ":name");
      }

      And suddenly, the name is valid.

      Is this the intended behavior, or is the JSF datatable not initialized properly?


      This code snippet also returns NULL for the value of the textfield (though it finds the component for the ID):
      HtmlOutputText outputText = (HtmlOutputText) this.server.findComponent("mytable:" + iRow + ":name");
      System.out.println ("Value of text field: " + outputText.getValue());

      With "setRowIndex" the component value is valid.

      Thanks

      Wolfgang

        1 2 Previous Next