Button.click() method inconsistency?

Hi,

I extended a FileDownloader with a button:

myFileDownLoader.extend(myButton);

Works fine if the user clicks the button.
But fails if I programmatically call

myButton.click();

My question: is this a bug or is this ‘by design’?
In my opinion the click method simulates a user click on a button and hence should activate the ‘associated functionality’, either through the extension(s) or through the clickListener (independent of the mechanism).

Regards,
Joost

By design. The idea with FileDownloader is that it starts the download directly on the client side when the user clicks the button (as opposed to after a server visit) to avoid problems with browsers blocking downloads.

Thanks Artur, for your quick response. Not completely satisfactory though: your desing explanation relates to the FileDownloader, not to the Button and I do feel an inconsistency in the button behaviour.

The deeper reason for my question is that I am still struggling with a vaadin6-7 migration problem regarding downloading dynamically created content (some similar problems mentioned by David Wall in
this wiki page
.

Unfortunaletly the downloader is still not documented in the vaadin book (html nor pdf) so I am doing some trial and error experiments. The last experiment involved the following steps:

  • create dynamic content (variable number of files)
  • create temporaryButton
  • extend FileDownloader(s) to temporaryButton
  • temporaryButton.click() to start download

and that failed (by design …).

Joost

Button.click() does everything click-related that happens
on the server side
- but FileDownloader works strictly on the client side. As Artur said, browsers require an actual user-originated click for file downloads to work without issues - it’s not possible to emulate or trigger from the server side, otherwise we wouldn’t need FileDownloader in the first place! If you can live with the fact that some browsers might prevent downloads or ask for user confirmation, you can just add a regular server-side ClickListener that starts the download using Page.open() or a Link component.

That was basically my vaadin6 solution. Not ideal, but acceptable.
Unfortunately that method is now deprecated and moreover: does not work anymore with nonASCII filenames (as it did work in vaadin6).

forum timing problem?

If it fails with non-ASCII filenames and has worked before, you could
open a ticket
.


done