View Full Version : RowEditor save error

10 Aug 2009, 5:47 AM

While editing a row in a grid trough a rowEditor a save button is disabled when at least one field is not valid.

When I press enter on a keyboard the row editor calls method stopEditing with true(saveChanges) even though fields are NOT valid and therefore red.

I'd expect that you can press enter only when the save button is visible.

Is this a bug?

10 Aug 2009, 6:06 AM
Please see at the method. If the editor is not valid, than nothign gets saved. Moving this to the help forum.

10 Aug 2009, 6:09 AM

but it still calls the stopEditing method with a parameter true instead of false.

Secondly, the enter key is a substitute for pressing the save buton. If the save button is disasbled then the enter key should be ignored or show some kind of error message.

It's a bug.

When I look at the method:

publicvoid onComponentEvent(ComponentEvent ce) {
if (ce.getEventTypeInt() == KeyNav.getKeyEvent().getEventCode()) {
if (ce.getKeyCode() == KeyCodes.KEY_ENTER) {
} elseif (ce.getKeyCode() == KeyCodes.KEY_ESCAPE) {

Nothing checks here if the save button is allowed nor fields are valid and yet it calls the stopEditing button with true.


10 Aug 2009, 6:27 AM
Check the stopeditong method. If it is not valid. than it is like if you called it with false.

10 Aug 2009, 6:50 AM
Dear Sven,

I got your point. I'm trying to extend functionality of the RowEditor and therefore it is important for me to be able to extend it.

I can't see the reason why the enter key is populated when the save button is disabled and why I cannot stop it in the derived class. I believe this is a bug.

I cannot override onComponentEvent method since you call super.onComponentEvent.
I cannot override stopEditing method since you send a wrong value there.

Not mentioning that many fileds are private rather than protected.

Is there a way how I can fix this in my derived class? Or is this functionality a "feature" which nobody can change?

10 Aug 2009, 8:03 AM
another problem is that when a user inputs values to all fields and one of them is not valid then if he or she accidentally hits the enter key then the user looses all data he inputed.

I coded a hack which prevents this to happen:


publicvoid onComponentEvent(ComponentEvent ce) {

illegalStopEditingRequest = false;

if (ce.getEventTypeInt() == KeyNav.getKeyEvent().getEventCode())

if (ce.getKeyCode() == KeyCodes.KEY_ENTER)

illegalStopEditingRequest = true;


illegalStopEditingRequest = false;


27 Jul 2011, 5:28 AM
Just override createRowEditor:

public void stopEditing(boolean saveChanges) {
if (!isValid() && saveChanges) {
Info.display("Contents not valid",
"Cancel or correct contents");
return; // ENTER key was pressed but contents are not valid
// call roweditor, reenable grid, disable roweditor