PDA

View Full Version : NPE in GridSelectionModel onEditorKey()



eprice
15 Feb 2012, 12:39 PM
I have an EditorGrid where not all columns have an attached editor. When navigating the grid using the Tab key, I get a NPE. Somehow the editor is being returned as null.

In the onEditorKey() method of GridSelectionModel there is a check to see if the editor is null, but then the editor is used in the call to grid.walkCells().



public void onEditorKey(DomEvent e) {
int k = e.getKeyCode();
Cell newCell = null;
CellEditor editor = grid.editSupport.getActiveEditor();


switch (k) {
case KeyCodes.KEY_ENTER:
case KeyCodes.KEY_TAB:
e.stopEvent();
if (editor != null) {
editor.completeEdit();
}
if ((k == KeyCodes.KEY_ENTER && moveEditorOnEnter) || k == KeyCodes.KEY_TAB) {
/*
* if editor is null, as checked for above, then the lines below throw NPE
*/
if (e.isShiftKey()) {
newCell = grid.walkCells(editor.row, editor.col - 1, -1, callback, true);
} else {
newCell = grid.walkCells(editor.row, editor.col + 1, 1, callback, true);
}
}
break;


I'm not sure why the editor is null, as that should be the source of the event. So I'm looking into that. But in the case when the editor really is null, how can navigation continue to the next editable cell?

sven
15 Feb 2012, 1:06 PM
Can you please provide a fully working testcase implementing EntryPoint?