Download file button in Vaadin 23 and Lit

253 Views Asked by At

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.

0

There are 0 best solutions below