This is an automated email from the ASF dual-hosted git repository.
svenmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push:
new 0a1c335 WICKET-6701 configurable content disposition
0a1c335 is described below
commit 0a1c33574d08ad9afd2e36a24085d48cdf9efc3f
Author: espyrop <[email protected]>
AuthorDate: Fri Sep 20 23:05:13 2019 +0200
WICKET-6701 configurable content disposition
---
.../wicket/markup/html/link/DownloadLink.java | 23 +++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git
a/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java
b/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java
index 88e55da..b6d7290 100644
---
a/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java
+++
b/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java
@@ -61,11 +61,17 @@ public class DownloadLink extends Link<File>
* <p>
* By default is {@code null} and
* {@link
org.apache.wicket.settings.ResourceSettings#getDefaultCacheDuration()} is used.
- * </p>
*/
private Duration cacheDuration;
/**
+ * Controls whether the browser will save the file or display it inline.
+ * <p>
+ * The default is ATTACHMENT to initiate the browser file save dialog.
+ */
+ private ContentDisposition contentDisposition =
ContentDisposition.ATTACHMENT;
+
+ /**
* Constructor. File name used will be the result of
<code>file.getName()</code>
*
* @param id
@@ -180,7 +186,7 @@ public class DownloadLink extends Link<File>
}
}
}.setFileName(fileName)
-
.setContentDisposition(ContentDisposition.ATTACHMENT)
+ .setContentDisposition(contentDisposition)
.setCacheDuration(cacheDuration));
}
@@ -214,6 +220,17 @@ public class DownloadLink extends Link<File>
cacheDuration = duration;
return this;
}
-
+
+ /**
+ * Sets the content disposition of the request.
+ *
+ * @param contentDisposition
+ * the content disposition of the file
+ * @return this component
+ */
+ public DownloadLink setContentDisposition(ContentDisposition
contentDisposition) {
+ this.contentDisposition = contentDisposition;
+ return this;
+ }
}