Refresh page after download

Refresh page after download

  
Hi all,

I'm having a problem with my application:

I have a webblock inside a page. This webblock has a button executes an action (that based on 3 combox does diferent functions), at the end of this action i have a widget_Click to click on a hidden button that calls another action to download a file generated in the actions mentioned before, after i have a NotifyWidget that notifies the webblock. The notify action of the webblock is set to an action that prints a "Processed" message  and reloads de page.

The problem is: the file is always downloaded, BUT the refresh page part isnt always executed and when it is not executed i get an ajax hang and all the buttons stop responding unless page is reloaded manually. I get the "A carregar..." animation at the bottom of the page, meaning (i think) that is indeed an ajax error.

With debugger turned on the result is also inconclusive, meaning, it sometimes jumps to the refresh page after exiting the download action thus not causing any errors, other times it just stops at the download file and hangs. 


I havent managed to find the trigger for it to reload or not. I have no errors in error monitoring in platform.

If anyone knows if this is in fact random, or if there is a way to find what is causing this i would much appreciated if you could help.
Hi Pedro,

It's not easy to fit a Download operation with some extra AJAX-y logic because a file download is kind of the end of the line: you can't detect if/when it starts or finishes, etc. That's why on most sites where you download a software installer you have a message that says some sort of "your download should start automatically, if not click this link".

If you're mixing file downloads with AJAX logic, that's also the easiest way to go: process your logic and messages first and do the download as the final step. That's kind of similar with the setup you already seem to have with the exception that you seem to be running into timing issues: your download seems to be starting while your NotifyWidget logic is still running, so it's probably aborted by the download. A simple fix would be to add a delay between setting the Processed message and triggering the download.

Cheers,
Miguel
Hi Miguel,

Thanks for the quick answer. Just 1 question: how can achiev this delay between 1 action and the other?


(I managed to fix my problem by moving the download function call to the preparation of the page and set a parameter when i know there is a file to download or not)