setDisableOnClick Processing

Does setDisableOnClick(true) essentially equate to a ClickListener that calls setEnabled(false)? Or is it supposed to work independently on the client side?

What I was hoping for was that a button with setDisableOnClick(true) would repaint on the client before sending the click to the server. I have a long running database query and I want the button disabled while it runs. However, just calling setEnabled(false) in the click listener won’t work because the disabling won’t be sent to the client until the query has finished anyway. In my testing with Vaadin 7 beta 6, the button that has setDisableOnClick(true) isn’t being disabled until its click handler finishes processing the database query.

Is this a bug or working as desired?

If this is working as desired, is there a standard design pattern for dealing with long running server tasks such as large database queries?

A Button with setDisableOnClick(true) will do the following after a click on client side (in

  1. disable the widget button (future clicks won’t cause new events)
  2. a rpc call to server to disable the button on server side (the style won’t get updated until the state is updated back to client)
  3. a rpc call to server with the mouse details, this will cause the server side ClickEvent.

So actually the Button is disabled while the database query is running, but unfortunately the style is not yet updated. I can’t say if this is desired functionality or not because of cases like yours, and for the fact that the current implementation is not actually working in

One workaround could be to use disableOnClick(true) and do the database query in a background thread and have a Refresher solution (like
) for updating the UI when the query is done.

With Vaadin 7.0.7, I’m not sure how to re-enable a Button that’s been disabled on click (button.setDisableOnClic(true)) when using a FileDownloader.extends(button). I’d like the button to re-enable once the download has ended.

Also it would seem that setting enable=true during the file download does not work.

Basically using the pattern to generate dynamic downloads
, I re enabled the button when the content generation is completed , this has no effect…

I made a quick test and it seems like the getStream method is called before the actual button click event is.
That’s probably why it had no effect.

I don’t think the FileDownloader supports some kind of event or listener to find out when the download is finished as it just attaches the Resource Stream directly to the site from the client-side and doesn’t handle it from the server-side.

If you want to get a listener which gets called when the attaching of the file is done you may have to extend the FileDownloader and override the handleConnectorRequest method to add in some kind of listener.

Thanks for the advice.

As it is I have to add some better way handling errors before/during my content generation,
like field validation before my content is generate.

Will make a clean implementation with some entry points for listeners to handle this…