FileDownloader and CssLayout

For Vaadin 8, why does the FileDownloader not work with CssLayout? It mentions that it works with all AbstractComponents, which CssLayout extends, but nothing is triggered when clicked.

I tried it with other components such as Button or Panel and the download is started as expected.


works for me. I did the following test app:

public class MyUI extends UI {

    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();

        CssLayout button = new CssLayout();
        StreamResource sr = new StreamResource(new StreamResource.StreamSource() {
            public InputStream getStream() {
                return new ByteArrayInputStream("foo".getBytes());
        }, "foo.txt");
        FileDownloader fd = new FileDownloader(sr);




    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {

in my theme:

  .foo {
    background-color: red;

Clicking the red CssLayout does indeed load a text file foo.txt with the content foo.


My bad, I was still using setCaption from an example using a Button. This does not trigger the event apparently. Changing this to actually adding content to the CssLayout fixed the issue. Thanks for the reply.

Yep; as you discovered there, the caption is not a part of the component itself :slight_smile:

Good to hear you solved the issue.