summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaxschuster <dev@maxschuster.eu>2016-02-22 00:10:21 +0100
committerTeemu Suo-Anttila <teemusa@vaadin.com>2016-03-08 13:59:17 +0200
commit39409784dfdce456d1e6e1054288c7e446c2cd49 (patch)
treed723eff09ac904b5d0c3aad2b4a18ddb85ee3cfa
parent96da1ff946c0d93deadcc04146b70d217c78b393 (diff)
downloadvaadin-framework-39409784dfdce456d1e6e1054288c7e446c2cd49.tar.gz
vaadin-framework-39409784dfdce456d1e6e1054288c7e446c2cd49.zip
Fix DragAndDropWrapper update after file upload (#19616)
After a file has been uploaded VDragAndDropWrapper tries to pull changes from the server by calling ApplicationConnection.sendPendingVariableChanges() which has no effect. This change replaces the ApplicationConnection.sendPendingVariableChanges() call with an RPC. Change-Id: If8abc662d4761969e5aa8e6327bfd4bdd7f5e905
-rw-r--r--client/src/com/vaadin/client/ui/VDragAndDropWrapper.java15
-rw-r--r--client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java16
-rw-r--r--server/src/com/vaadin/ui/DragAndDropWrapper.java10
-rw-r--r--shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperServerRpc.java36
4 files changed, 73 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
index f3905f9e46..a4cdd6e70f 100644
--- a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
+++ b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
@@ -196,6 +196,9 @@ public class VDragAndDropWrapper extends VCustomComponent implements
/** For internal use only. May be removed or replaced in the future. */
public VAbstractDropHandler dropHandler;
+ /** For internal use only. May be removed or replaced in the future. */
+ public UploadHandler uploadHandler;
+
private VDragEvent vaadinDragEvent;
int filecounter = 0;
@@ -239,9 +242,9 @@ public class VDragAndDropWrapper extends VCustomComponent implements
@Override
public void onReadyStateChange(XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
- // visit server for possible
- // variable changes
- client.sendPendingVariableChanges();
+ // #19616 Notify the upload handler that the request is complete
+ // and let it poll the server for changes.
+ uploadHandler.uploadDone();
uploading = false;
startNextUpload();
xhr.clearOnReadyStateChange();
@@ -727,4 +730,10 @@ public class VDragAndDropWrapper extends VCustomComponent implements
return dragImageWidget;
}
+ public interface UploadHandler {
+
+ public void uploadDone();
+
+ }
+
}
diff --git a/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java b/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java
index f222721e24..7ea9596809 100644
--- a/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java
+++ b/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java
@@ -30,11 +30,18 @@ import com.vaadin.client.ui.VDragAndDropWrapper;
import com.vaadin.client.ui.customcomponent.CustomComponentConnector;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperConstants;
+import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperServerRpc;
import com.vaadin.ui.DragAndDropWrapper;
@Connect(DragAndDropWrapper.class)
public class DragAndDropWrapperConnector extends CustomComponentConnector
- implements Paintable {
+ implements Paintable, VDragAndDropWrapper.UploadHandler {
+
+ @Override
+ protected void init() {
+ super.init();
+ getWidget().uploadHandler = this;
+ }
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
@@ -121,4 +128,11 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector
private static Logger getLogger() {
return Logger.getLogger(DragAndDropWrapperConnector.class.getName());
}
+
+ @Override
+ public void uploadDone() {
+ // #19616 RPC to poll the server for changes
+ getRpcProxy(DragAndDropWrapperServerRpc.class).poll();
+ }
+
}
diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java
index 90b3b56ef6..29179ddca7 100644
--- a/server/src/com/vaadin/ui/DragAndDropWrapper.java
+++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java
@@ -40,6 +40,7 @@ import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.dd.HorizontalDropLocation;
import com.vaadin.shared.ui.dd.VerticalDropLocation;
import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperConstants;
+import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperServerRpc;
import com.vaadin.ui.declarative.DesignContext;
@SuppressWarnings("serial")
@@ -111,6 +112,14 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
}
+ private final DragAndDropWrapperServerRpc rpc = new DragAndDropWrapperServerRpc() {
+
+ @Override
+ public void poll() {
+ // #19616 RPC to poll the server for changes
+ }
+ };
+
private Map<String, ProxyReceiver> receivers = new HashMap<String, ProxyReceiver>();
public class WrapperTargetDetails extends TargetDetailsImpl {
@@ -197,6 +206,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
@Deprecated
public DragAndDropWrapper() {
super();
+ registerRpc(rpc);
}
/**
diff --git a/shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperServerRpc.java b/shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperServerRpc.java
new file mode 100644
index 0000000000..d5100aba3f
--- /dev/null
+++ b/shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperServerRpc.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared.ui.draganddropwrapper;
+
+import com.vaadin.shared.communication.ServerRpc;
+
+/**
+ * RPC interface for calls from client to server.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public interface DragAndDropWrapperServerRpc extends ServerRpc {
+
+ /**
+ * Called to poll the server to see if any changes have been made e.g. when
+ * the upload is complete.
+ *
+ * @since
+ */
+ public void poll();
+
+}