diff options
author | Ilia Motornyi <elmot@vaadin.com> | 2017-03-09 09:29:20 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-03-09 09:29:20 +0200 |
commit | 264ee7696568827815604f1e22ce7e330775b3ce (patch) | |
tree | 70bda37d99e4cc0b328c6e65ef70ec2e0504debf | |
parent | 82ea08974b1c5510da0b2c59d0c9e3edb768f6bb (diff) | |
download | vaadin-framework-264ee7696568827815604f1e22ce7e330775b3ce.tar.gz vaadin-framework-264ee7696568827815604f1e22ce7e330775b3ce.zip |
Fix Upload and push in TabSheet (#8782)
Also fixes JSNI calls in compatibility Upload component.
Fixes #8728 for the compatibility package
5 files changed, 88 insertions, 6 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java index 8f892e377e..4969f19933 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java @@ -249,10 +249,12 @@ public class VUpload extends SimplePanel { t.cancel(); } VConsole.log("VUpload:Submit complete"); - ((UploadConnector) ConnectorMap.get(client) - .getConnector(VUpload.this)) - .getRpcProxy(UploadServerRpc.class) - .poll(); + if (isAttached()) { + // no need to call poll() if component is already + // detached #8728 + ((UploadConnector) ConnectorMap.get(client).getConnector(VUpload.this)) + .getRpcProxy(UploadServerRpc.class).poll(); + } } rebuildPanel(); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategy.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategy.java index c01fce1b50..d842fc8e01 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategy.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategy.java @@ -23,7 +23,7 @@ public class UploadIFrameOnloadStrategy { VUpload upload) /*-{ iframe.onload = $entry(function() { - upload.@com.vaadin.client.ui.VUpload::onSubmitComplete()(); + upload.@com.vaadin.v7.client.ui.VUpload::onSubmitComplete()(); }); }-*/; diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategyIE.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategyIE.java index a40abfafdf..cac9481986 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategyIE.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadIFrameOnloadStrategyIE.java @@ -28,7 +28,7 @@ public class UploadIFrameOnloadStrategyIE extends UploadIFrameOnloadStrategy { /*-{ iframe.onreadystatechange = $entry(function() { if (iframe.readyState == 'complete') { - upload.@com.vaadin.client.ui.VUpload::onSubmitComplete()(); + upload.@com.vaadin.v7.client.ui.VUpload::onSubmitComplete()(); } }); }-*/; diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadInTabsheetV7.java b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadInTabsheetV7.java new file mode 100644 index 0000000000..64de1cde1d --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadInTabsheetV7.java @@ -0,0 +1,41 @@ +package com.vaadin.tests.components.upload; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Label; +import com.vaadin.v7.ui.Upload; + +import java.io.ByteArrayOutputStream; + +/** + * Test UI for case where Upload is in a TabSheet and Tab is changed directly + * after Upload Succeed + */ +@Push +public class UploadInTabsheetV7 extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + TabSheet t = new TabSheet(); + Upload upload = new Upload("Upload", (filename, mimeType) -> new + ByteArrayOutputStream()); + upload.setImmediate(false); + upload.addSucceededListener(event -> upload.getUI().access(()->{ + t.setSelectedTab(1); + })); + upload.setWidthUndefined(); + + t.addComponent(upload); + t.addComponent(new Label("Second tab")); + + addComponent(t); + } + + @Override + protected Integer getTicketNumber() { + return 8728; + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetV7Test.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetV7Test.java new file mode 100644 index 0000000000..051cf7a56e --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetV7Test.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2016 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.tests.components.upload; + +import com.vaadin.testbench.elements.UploadElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.internal.WrapsElement; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebElement; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; + +/** + * Verifies that there's no client side errors when changing a tab containing + * Upload right after uploading is succeeded (#8728) + */ +public class UploadInTabsheetV7Test extends UploadInTabsheetTest { +} |