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.
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.
- relates to
-
JDK-8123209 ListView and possibly TableView and TreeView call Cell.updateItem() when the item hasn't changed.
-
- Resolved
-