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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Due:
                Created:
                Updated:
                Resolved:
                Imported: