1

I'm using Vaadin 23 in Java application in Spring. I have a lit template with render method returning html like this:

import {css, html, LitElement} from 'lit-element';

class DownloadButton extends LitElement {

    render() {
        return html`
          <button @click="${this.download}">
            <span>Download file</span>
          </button>
    `;
    }


    download() {
        ...
    }

...

The question is: how to make this button to initiate a file download?

When using Vaadin views defined in Java I'd use FileDownloader addon, but this time it's Lit and I have no idea how to wire it here. I can also call backend methods like this: rootObserver.$server.someJavaMethod(); but still no idea how to download a file.

Krystian G
  • 2,842
  • 3
  • 11
  • 25
  • Ate you still using this component in Flow? If yes, then I would recommend not go this way as it is the server that serves the file. Or are you using the component in Hilla project? – Tatu Lund May 11 '23 at 04:01
  • I'm using Flow. – Krystian G May 13 '23 at 08:47
  • Ok. Then use Anchor in Flow or the FileDownloader add-on. The file is served against resource url, so yo do not gain much with Lit element here. – Tatu Lund May 15 '23 at 06:13

0 Answers0