Dynamic file downloads

It seems that Vaadin 7 has suggested that StreamResources are problematic and suggests using URLs. What was the issue with a StreamResource? It seems like it was a good concept for dynamic data downloads in which I only retrieved and downloaded the data when a button was clicked.

How is this done in Vaadin 7? I’m looking for a complete, simple example, say, of downloading a PDF or ZIP file that is generated ONLY IF a button is clicked. There is no point in creating dynamic data just in case they click the download button, so it should only occur if they click it. I saw the wiki https://vaadin.com/wiki/-/wiki/Main/Letting+the+user+download+a+file#_36_messageScroll3298283, but I’m not really sure how to make use of it.

The javadocs suggest page.open() is deprecated and should use setLocation(String url) instead, but to use an URL, that means moving all of my downloads from simple button click listeners to something like a servlet where I can generate an URL so that it can then retrieve and download the resource. I hope it doesn’t have to be that hard since it was pretty straightforward under Vaadin 6.