Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8124826

Cell with null initial value cannot be edited because the empty property is true

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx

      In a TableView when the cell value is null, the Cell's empty property is true by mistake. This causes this cell can't start editing.

      The root reason is in updateItem method of TableCell, we have

                  // update the 'item' property of this cell.
                  if ((newValue != null && ! newValue.equals(oldValue)) ||
                          oldValue != null && ! oldValue.equals(newValue)) {
                      updateItem(newValue, false);
                  }

      When the newValue is null (and the oldValue is also null), this "if" statement is bypassed. I don't see a reason that a null newValue should be ignored. Because updateItem(xxx, false) is not called, the empty property remains the default value which is true. A fix is to add an else statement and call

      else if(isEmpty() && newValue == null) {
          update(newValue, false);
      }

      because I believe even both oldValue and newValue are null, updateItem(null, false) will at least give the Cell a chance to initialize itself even with a null value.

            jgiles Jonathan Giles
            dqiaojfx David Qiao (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: