Wicket
  1. Wicket
  2. WICKET-4623

UploadProgressBar does not show up if the form submitted by AjaxButton or AjaxLink

    Details

      Description

      If I submit the form normal submit button then the progressbar shows up. If I do it with any ajax component (AjaxLink, AjaxButton ...) then it does not show.
      I set up setOutputMarkupPlaceholderTag(true) for progressbar itself and it's parent component (the form) but it has not helped.

      1. WICKET-4623.patch
        4 kB
        Martin Grigorov
      2. WICKET-4623-with-ajax-update.patch
        6 kB
        Sven Meier
      3. test.zip
        22 kB
        Sandor Feher

        Issue Links

          Activity

          Hide
          Sven Meier added a comment -

          I've added a progressBar to example's FileUploadPage (don't forget getApplicationSettings().setUploadProgressUpdatesEnabled(true)) and can confirm the issue.

          Problem is that the request for the upload status (UploadStatusResource) is coming in earlier than the actual upload via ajax. Thus no UploadInfo is found in the session and the progressBar assumes the upload to have finished.

          A the moment I don't have an idea how to fix this.

          Show
          Sven Meier added a comment - I've added a progressBar to example's FileUploadPage (don't forget getApplicationSettings().setUploadProgressUpdatesEnabled(true)) and can confirm the issue. Problem is that the request for the upload status (UploadStatusResource) is coming in earlier than the actual upload via ajax. Thus no UploadInfo is found in the session and the progressBar assumes the upload to have finished. A the moment I don't have an idea how to fix this.
          Hide
          Martin Grigorov added a comment -

          Here is a "solution" that keeps the UploadInfo in the HttpSession until it is read at least once.

          The problem is that this way it may leak but it has just 3 'long' fields and one 'boolean'.

          Show
          Martin Grigorov added a comment - Here is a "solution" that keeps the UploadInfo in the HttpSession until it is read at least once. The problem is that this way it may leak but it has just 3 'long' fields and one 'boolean'.
          Hide
          Sven Meier added a comment -

          Note that MultipartServletWebRequestImpl uses #getUploadInfo() itself. So in rare cases it could mark the uploadInfo as readOnce and remove it from session already before the UploadStatusResource has accessed it. Wouldn't that make the progressbar running forever?

          What about making ProgressBar smarter (i.e. let it extend FormComponentPanel) so that it updates itself on ajax form submit? No need then for the UploadStatusResource to signal the end of upload. It could just return "0|" when no info avaiable, as you've changed it.

          Show
          Sven Meier added a comment - Note that MultipartServletWebRequestImpl uses #getUploadInfo() itself. So in rare cases it could mark the uploadInfo as readOnce and remove it from session already before the UploadStatusResource has accessed it. Wouldn't that make the progressbar running forever? What about making ProgressBar smarter (i.e. let it extend FormComponentPanel) so that it updates itself on ajax form submit? No need then for the UploadStatusResource to signal the end of upload. It could just return "0|" when no info avaiable, as you've changed it.
          Hide
          Sven Meier added a comment -

          Update progressBar on ART and just let UploadStatusResource running even if no UploadInfo available.

          Show
          Sven Meier added a comment - Update progressBar on ART and just let UploadStatusResource running even if no UploadInfo available.
          Hide
          Sven Meier added a comment -

          I've checked in a small fix needed on master for the progressBar to hide again on Ajax upload.

          @Sandor
          Could you please check whether the problem still persists?
          After much tinkering with Ajax upload I don't understand how the actual upload can be delayed to arrive after the first status update, which is fired at least 1 seconds later.
          In my tests I was able to reproduces this only if I put a breakpoint in the upload processing, thus preventing storing of UploadInfo in the session before the status update request tried to look it up again.

          Show
          Sven Meier added a comment - I've checked in a small fix needed on master for the progressBar to hide again on Ajax upload. @Sandor Could you please check whether the problem still persists? After much tinkering with Ajax upload I don't understand how the actual upload can be delayed to arrive after the first status update, which is fired at least 1 seconds later. In my tests I was able to reproduces this only if I put a breakpoint in the upload processing, thus preventing storing of UploadInfo in the session before the status update request tried to look it up again.
          Hide
          Sandor Feher added a comment -

          Sven Meier

          Sure. Give me some time pls.

          Show
          Sandor Feher added a comment - Sven Meier Sure. Give me some time pls.
          Hide
          Sandor Feher added a comment -

          Okay. I made a quickstart cut off my upload form's relevant part and tested it. (I use 1.5.x branch so I could not try it in my project). Now I'm a little bit confused. Progressbar shows up in both cases (even with AjaxLink or Button) but does not show the progress. Moreover if I try to upload a bigger file to see the progress the bar disappears after few seconds.
          It might be something wrong with my quickstart I don't know. Attached it. Please check.

          Show
          Sandor Feher added a comment - Okay. I made a quickstart cut off my upload form's relevant part and tested it. (I use 1.5.x branch so I could not try it in my project). Now I'm a little bit confused. Progressbar shows up in both cases (even with AjaxLink or Button) but does not show the progress. Moreover if I try to upload a bigger file to see the progress the bar disappears after few seconds. It might be something wrong with my quickstart I don't know. Attached it. Please check.
          Hide
          Sandor Feher added a comment -

          Quickstart project for testing WICKET-4623

          Show
          Sandor Feher added a comment - Quickstart project for testing WICKET-4623
          Hide
          Sven Meier added a comment -

          You've forgot getApplicationSettings().setUploadProgressUpdatesEnabled(true);

          Show
          Sven Meier added a comment - You've forgot getApplicationSettings().setUploadProgressUpdatesEnabled(true);
          Hide
          Sandor Feher added a comment -

          I thought so . But I tried it again. Both cases worked fine . So I'm happy. I would more happy if you could backport this nice feature into 1.5.x branch .

          Show
          Sandor Feher added a comment - I thought so . But I tried it again. Both cases worked fine . So I'm happy. I would more happy if you could backport this nice feature into 1.5.x branch .
          Hide
          Sven Meier added a comment -

          I've added the upload progress to the examples in 1.5.x too. Works fine here now.

          Show
          Sven Meier added a comment - I've added the upload progress to the examples in 1.5.x too. Works fine here now.

            People

            • Assignee:
              Sven Meier
              Reporter:
              Sandor Feher
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development