MyFaces Tomahawk
  1. MyFaces Tomahawk
  2. TOMAHAWK-1566

Nested Table - odd behavior when calling setRowIndex

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I have tables nested 3 levels deep and when the user clicks an Update button I need to get the value of a selectBooleanCheckbox that is contained in the inner most table. I have a recursive method which calls setRowIndex on the UIData - it loops through the root table rows, and for each row in that table, calls the method to loop through the second level table rows, etc. So, the root table index gets set to 0, and it then loops through the 2nd level table rows, sets the index to 0, and then loops through the innermost table rows, checking the value of the check box. I called getAttributes().get("value") on the UIData to get the list of rows. When the checkbox is checked, I need to remove the row, so I call list.remove(row) to do so. I then used setValue on UIData to set the value to the new list, after removing the row.

      I have seen some strange behavior, so I'm wondering if this programatic setting of rows is an ok approach. The reason I'm using it is because the application is a generic one that supports plugging in new data types, which use the same type of page for the user to add/delete child objects for the data type.

      The strange behavior I have seen is:
      1. The getValue method on the check box - it often returns false, even when it is checked. It always seems to return the correct value for the rows in the first row of the second level table (outermost table index set to 0, second level table index set to zero), but returns false for the first row for all other row values in the second level table (outermost table index set to 0, second level table index set to anything greater than 0). My outer most table only has 1 entry at the moment, so I don't know what would happen if this had more rows.
      2. When I remove a row and then call setValue(newListWithRowRemoved), it seems that this list becomes the value for all row indexes of the second level table. For example, I set the index of the outer most table to zero, set the index of the second level table to 0, and then loop through the rows in the inner most table. I see that the checkbox is checked for row 1, I remove the row, and call setValue on the UIData for the inner most table. I then continue looping through, setting the index of the second level table to 1, and checking all the rows in the inner most table. The rows of the inner most table will now have the values from when the second level table had it's index set to 0, even though the second level table now has its index set to 1.

        Issue Links

          Activity

          Hide
          Mike Kienenberger added a comment -

          Try using t:dataTable with preserveRowStates=true and see if that works. JSF RI 1.2 handles nested UIData components by always preserving the row state.

          Show
          Mike Kienenberger added a comment - Try using t:dataTable with preserveRowStates=true and see if that works. JSF RI 1.2 handles nested UIData components by always preserving the row state.
          Hide
          Leonardo Uribe added a comment -

          This issue (previously reported MYFACES-1313 and then moved to tomahawk) is part of TOMAHAWK-1552. The problem is caused because the state is bound to the rowIndex and the solution there tries to bind that to other identifier more related to the row.

          Show
          Leonardo Uribe added a comment - This issue (previously reported MYFACES-1313 and then moved to tomahawk) is part of TOMAHAWK-1552 . The problem is caused because the state is bound to the rowIndex and the solution there tries to bind that to other identifier more related to the row.
          Hide
          Leonardo Uribe added a comment -

          Duplicate of TOMAHAWK-961

          Show
          Leonardo Uribe added a comment - Duplicate of TOMAHAWK-961

            People

            • Assignee:
              Leonardo Uribe
              Reporter:
              Gina Marksteiner
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development