viritin / flow-viritin

Viritin inspired project for Vaadin Flow
Other
43 stars 16 forks source link

DynamicFileDownloader: eventlisteners not triggering #51

Closed jorgheymans closed 5 months ago

jorgheymans commented 5 months ago

Too many people struggle this, because nobody uses JavaDoc. Lenient log message and setting polling on automatically would work well enought in 99.9% of the cases.

Original bug report:

I have a DynamicFileDownloader with this:

      setDisableOnClick(true);
      addDownloadFinishedListener(e -> setEnabled(true));
      addDownloadFailedListener(e -> setEnabled(true));

but when clicked, the button always stays disabled. Putting breakpoints, i see that the events are indeed fired.

Looking at the code, should the events not be broadcasted rather using this: ComponentUtil.fireEvent(UI.getCurrent(), new DownloadFinishedEvent(DynamicFileDownloader.this, false) );

mstahv commented 5 months ago

Do you have Push or polling set?

Adds a listener that is executed when the file content has been streamed. Note that the UI changes done in the listener don't necessarily happen live if you don't have @com.vaadin.flow.component.page.Push in use or use UI.setPollInterval(int) method.

If so, I think you are the third hitting this issue. There should probably be some "AI" in the logic that sets e.g. polling if Push or polling is set up 🤔

jorgheymans commented 5 months ago

I missed that part apologies, we don't have push or polling set in the application. So, the behaviour is as expected.

mstahv commented 5 months ago

But it clearly isn't as so many people have reported that (and probably more 10x faced it but not reported). I'll coop this issue for making the logic smarter...

mstahv commented 5 months ago

I noticed there was also a recent regression I introduced when trying to improve compatibility with certain Spring Security setups. Fixed that in the same changeset. Cutting release now...