diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/connectors/GridConnector.java | 27 | ||||
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 7 |
2 files changed, 19 insertions, 15 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 93e2b0568d..488dac37ef 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -210,8 +210,13 @@ public class GridConnector extends AbstractHasComponentsConnector implements @Override public void bind(final int rowIndex) { - serverInitiated = true; - GridConnector.this.getWidget().editRow(rowIndex); + // call this finally to avoid issues with editing on init + Scheduler.get().scheduleFinally(new ScheduledCommand() { + @Override + public void execute() { + GridConnector.this.getWidget().editRow(rowIndex); + } + }); } @Override @@ -223,7 +228,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements @Override public void confirmBind(final boolean bindSucceeded) { endRequest(bindSucceeded); - } @Override @@ -235,18 +239,14 @@ public class GridConnector extends AbstractHasComponentsConnector implements @Override public void bind(EditorRequest<JsonObject> request) { - if (!handleServerInitiated(request)) { - startRequest(request); - rpc.bind(request.getRowIndex()); - } + startRequest(request); + rpc.bind(request.getRowIndex()); } @Override public void save(EditorRequest<JsonObject> request) { - if (!handleServerInitiated(request)) { - startRequest(request); - rpc.save(request.getRowIndex()); - } + startRequest(request); + rpc.save(request.getRowIndex()); } @Override @@ -296,11 +296,13 @@ public class GridConnector extends AbstractHasComponentsConnector implements } private void startRequest(EditorRequest<?> request) { + assert currentRequest == null : "Earlier request not yet finished"; + currentRequest = request; } private void endRequest(boolean succeeded) { - assert currentRequest != null; + assert currentRequest != null : "Current request was null"; /* * Clear current request first to ensure the state is valid if * another request is made in the callback. @@ -406,6 +408,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements protected void init() { super.init(); + // All scroll RPC calls are executed finally to avoid issues on init registerRpc(GridClientRpc.class, new GridClientRpc() { @Override public void scrollToStart() { diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 01decd1386..980261c452 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -944,7 +944,7 @@ public class Grid<T> extends ResizeComposite implements public static final int KEYCODE_HIDE = KeyCodes.KEY_ESCAPE; protected enum State { - INACTIVE, ACTIVATING, ACTIVE, SAVING + INACTIVE, ACTIVATING, BINDING, ACTIVE, SAVING } private Grid<T> grid; @@ -1018,7 +1018,7 @@ public class Grid<T> extends ResizeComposite implements private final RequestCallback<T> bindRequestCallback = new RequestCallback<T>() { @Override public void onSuccess(EditorRequest<T> request) { - if (state == State.ACTIVATING) { + if (state == State.BINDING) { state = State.ACTIVE; bindTimeout.cancel(); @@ -1029,7 +1029,7 @@ public class Grid<T> extends ResizeComposite implements @Override public void onError(EditorRequest<T> request) { - if (state == State.ACTIVATING) { + if (state == State.BINDING) { state = State.INACTIVE; bindTimeout.cancel(); @@ -1188,6 +1188,7 @@ public class Grid<T> extends ResizeComposite implements protected void show() { if (state == State.ACTIVATING) { + state = State.BINDING; bindTimeout.schedule(BIND_TIMEOUT_MS); EditorRequest<T> request = new EditorRequest<T>(grid, rowIndex, bindRequestCallback); |