aboutsummaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorIlia Motornyi <elmot@vaadin.com>2018-08-07 15:49:49 +0300
committerGitHub <noreply@github.com>2018-08-07 15:49:49 +0300
commit156121c76953e2bbd2d66cf40fedf2d48cdac28d (patch)
tree9ac9a982cb3d6d4d9077f1cd9747ceafe8b15f0c /documentation
parent49f6f45cdf4895f179d9a630df6db096db3cdf66 (diff)
downloadvaadin-framework-156121c76953e2bbd2d66cf40fedf2d48cdac28d.tar.gz
vaadin-framework-156121c76953e2bbd2d66cf40fedf2d48cdac28d.zip
Document how to handle cancelled file downloads. (#11079)
Diffstat (limited to 'documentation')
-rw-r--r--documentation/articles/LettingTheUserDownloadAFile.asciidoc28
1 files changed, 26 insertions, 2 deletions
diff --git a/documentation/articles/LettingTheUserDownloadAFile.asciidoc b/documentation/articles/LettingTheUserDownloadAFile.asciidoc
index 4b595fc6de..f977b07956 100644
--- a/documentation/articles/LettingTheUserDownloadAFile.asciidoc
+++ b/documentation/articles/LettingTheUserDownloadAFile.asciidoc
@@ -62,8 +62,7 @@ along with the file to ensure the browser doesn't try to open the file
even if it's is a file type that the browser knows how to deal with.
[[lazily-determine-the-content-and-the-name-of-the-file-being-server]]
-Lazily determine the content and the name of the file being server
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+==== Lazily determine the content and the name of the file being server
One can lazily determine the content of the file using a
`StreamResource`. Yet the name of the file that is going to be
@@ -110,3 +109,28 @@ public class OnDemandFileDownloader extends FileDownloader {
}
}
....
+
+[[lazily-determine-the-content-and-the-name-of-the-file-being-server]]
+==== Cancelled downloads
+
+Since downloadable files may be quite big, and the download process may take time, the user might decide to
+cancel the download process. In this case `IOException` may be thrown by the web server. That
+does not mean something went wrong with the application, but the user pressed `Cancel` button during download. To prevent the exception to be logged, you can catch and ignore it as here:
+
+```java
+public class IgnoreCancelDownloader extends FileDownloader {
+
+ ...
+
+ @Override
+ public boolean handleConnectorRequest(final VaadinRequest request, final VaadinResponse response, final String path) {
+ try {
+ return super.handleConnectorRequest(request, response, path);
+ } catch (final IOException ignored) {
+ return true;
+ }
+ }
+}
+
+```
+Note that the exception is a sublclass of `IOException`, but the particular class depends on the web container.