Repository navigation
docs: pass AttachmentType.INLINE to serve a download inline - #6758
Conversation
Anchor's AttachmentType now decides on its own whether a built-in download handler is served inline or as an attachment, so the handler no longer needs its own inline() call for that. Updates the file system download example on the Downloads page accordingly, and adds a warning about serving untrusted content inline. Documents vaadin/flow#27088 (`12974d1c4b622b8dda573e854e499fb84c5abd67`).
Preview DeploymentThis PR has been deployed for preview. URL: https://docs-preview-pr-6758.fly.dev Changed pagesAdded content is highlighted in green; removed content is marked in red on each page.
Built from 75ea15a |
vaadin-review-bot
left a comment
There was a problem hiding this comment.
Reviewed the changes — left 2 comments.
| Finding | |
|---|---|
The same page still teaches the deprecated inline() call that this change removes |
|
| 📐 | The 25.4 behavior change has no since badge, unlike the neighbouring statements |
There was a problem hiding this comment.
Around line 398 — could not attach to the exact diff line.
inline() call that this change removes
Line 164 now says that AttachmentType.INLINE on the Anchor decides this, but 230 lines further down the page still says the opposite:
When [classname]
DownloadHandleris used withAnchorcomponent, the data is downloaded as a file.
This can be changed to render the data in the browser by using [methodname]inline()method:
AbstractDownloadHandler.inline() is @Deprecated(since = "25.4", forRemoval = true) (flow-server/.../streams/AbstractDownloadHandler.java:178), and its Javadoc names AttachmentType.INLINE as the replacement for an Anchor. A reader who reaches that section first copies an API that disappears in Vaadin 26. Updating it the same way as the example above keeps the page consistent. (Its DownloadHandler.fromFile also doesn't exist — the method is forFile — which is worth fixing while rewriting those lines.)
downloads.adoc:398 · accuracy
There was a problem hiding this comment.
Fixed. The section further down no longer shows the deprecated handler inline() with fromFile(). It now links to the AttachmentType.INLINE example in Download A File From File System, so the page has one inline example, with the badge and the untrusted-content warning. The file-name sentence now names DownloadHandler.forFile(File, String).
|
|
||
| The [classname]`Anchor` component sets the `download` attribute by default and download handlers extending [classname]`AbstractDownloadHandler` also set the `Content-Disposition` to `attachment`. | ||
| If the content should be inlined to the page, this have to be set explicitly by calling the [methodname]`inline()` method on the `DownloadHandler` instance and using `AttachmentType.INLINE`: | ||
| The [classname]`Anchor` component sets the `download` attribute by default, and a handler that only gives a file name, as the built-in handlers do, is served as an attachment to match. Passing `AttachmentType.INLINE` to the [classname]`Anchor` constructor removes the attribute and serves that same content inline instead: |
There was a problem hiding this comment.
📐 The 25.4 behavior change has no since badge, unlike the neighbouring statements
That an AttachmentType on the Anchor decides the Content-Disposition is new in 25.4: it works through DownloadDisposition, which is @since 25.4 (flow-server/.../streams/DownloadDisposition.java:33). In 25.3 the handler's own inline() decided it, as the removed text said.
CONVENTIONS.md:82 says to mark new features with a since badge, and the two paragraphs above and the section below already carry [since:com.vaadin:vaadin@V25.4]. Wrapping the second sentence, the one about AttachmentType.INLINE, in a badge would match them.
downloads.adoc:164 · conventions
There was a problem hiding this comment.
Added [since:com.vaadin:vaadin@V25.4] around the AttachmentType.INLINE sentence. The Flow change was cherry-picked to 25.4.
….INLINE The Anchor section further down still used the deprecated handler inline() and a nonexistent fromFile() method. Use AttachmentType.INLINE and forFile() there too, and mark the AttachmentType behavior with a 25.4 since badge like the neighboring statements.
## Summary Two pages still chained the deprecated `AbstractDownloadHandler.inline()` (deprecated for removal in 25.4). This removes those calls. ## What changed - Map, "Styling Clusters": the custom cluster icon example no longer calls `.inline()`. Map serves icon images inline by itself in 25.4. - Building Apps, "Handle Downloads": the "Inline rendering" bullet no longer points to `inline()`. It says that components that show content, such as `Image`, already serve it inline, and that an `Anchor` takes `AttachmentType.INLINE` (with a 25.4 badge). The same deprecated call on the Downloads reference page is handled in #6758. ## Test summary - Checked against Flow and Flow Components 25.4: the `inline()` deprecation note, and the Map serializer registering icon images with `DownloadDisposition.INLINE`. Working on behalf of Petter --------- Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Documentation for vaadin/flow#27088 by
@totally-not-ai[bot].Note
The source pull request is merged, so this documentation describes the final
shape of the change. Please review it and mark it ready for review.
Change categories: BEHAVIOR_CHANGE, BREAKING_CHANGE
articles/flow/advanced/downloads.adocAnchor'sAttachmentTypenow decides on its own whether a built-in handler is served inline or as an attachment, so the example no longer needs a separate.inline()call on the handler. Added a warning about serving untrusted content inline, and a 25.4sincebadge on theAttachmentType.INLINEsentence. In the Custom Download Handlers section, replaced the example that used the deprecated handlerinline()and a nonexistentfromFile()with a link to the file-system example, and namedforFile(File, String)for the file-name parameter.Auto-generated by the Documentation Bot — review before merging.