The JavaDocs for the component’s constructor are faulty:
/**
* Creates a download button. The first two parameters are used for the button displayment.
* <p/>
* The third callback is called, when the download button is clicked. This is called inside the UI thread before
* the input stream generation starts. It can be used for instance to deactivate the button.
* <p/>
* The fourth parameter is a callback, that is used to generate the download file name
* <p/>
* The fifth parameter is a callback to generate the input stream sent to the client. This callback will be
* called in a separate thread (so that the UI thread is not blocked).
* <p/>
* The sixth callback is called when the download anchor on the client side has been clicked (means the input
* stream content is now sent to the user). This callback is called inside the UI thread.
* BE AWARE THAT THE FILE IS STILL SENT TO THE CLIENT AT THIS POINT. Deleting or removing things can interrupt the
* download.
*
But there are only four parameters, two of which are callbacks (i.e. there is no “fifth” or “sixth” parameter/callback).
I am also missing any callback when the download is terminated (either completed or aborted). I.e. by when could I remove the “Prepare downloading”- or the “Downloading”-indication in the UI and re-enable the button (referring to the code example 2)?
It would also be cool, if the widget would more gracefully react if the name and/or the content callback return null (e.g. because they are for whatever reason not able to provide a name and/or content). It should then just return and do nothing instead of throwing NPEs.