thatone
23 Mar 2009, 1:26 PM
I recently came across a ClassCastException when a cancelEdit is executed. When I traced the code, I found the problem in here:
protected void cancelEdit(boolean remainVisible) {
if (editing) {
setValue(startValue);
if (!remainVisible) {
hide();
}
}
}
If my CellEditor overrides pre/post ProcessValue() methods, then cancelEdit would throw ClassCastException because startValue is a "unconverted" value.
The following is the excerpt code from startEdit(Element el, Object value) around line 382-383.
startValue = value;
field.setValue(preProcessValue(value));
The fix for this bug can either be:
1) fix CellEditor.startEdit() to
startValue = preProcessValue(value)
2) CellEditor.cancelEdit() to
setValue(preProcessValue(startValue));
3) CellEditor.setValue() to
field.setValue(preProcessValue(startValue));
protected void cancelEdit(boolean remainVisible) {
if (editing) {
setValue(startValue);
if (!remainVisible) {
hide();
}
}
}
If my CellEditor overrides pre/post ProcessValue() methods, then cancelEdit would throw ClassCastException because startValue is a "unconverted" value.
The following is the excerpt code from startEdit(Element el, Object value) around line 382-383.
startValue = value;
field.setValue(preProcessValue(value));
The fix for this bug can either be:
1) fix CellEditor.startEdit() to
startValue = preProcessValue(value)
2) CellEditor.cancelEdit() to
setValue(preProcessValue(startValue));
3) CellEditor.setValue() to
field.setValue(preProcessValue(startValue));