2

In a GWT application, I am using the fileupload widget and when I upload the first file then it shows progressbar corresponding file size and after completion of uploading, the progress bar hides and then I upload second file this time shows both progressbar of first file and second file. To solve this problem I refresh the page using Window.Location.reload(); after uploading the first file, then it doesn't show the progressbar of the first file while uploading second file, it runs smooth. But there is no meaning of asynchronous of gwt. So how can I resolve this problem?

Thanks rahul

Jesper
  • 202,709
  • 46
  • 318
  • 350
rahul
  • 41
  • 1
  • 5

2 Answers2

9

Use fileUploadWidget.getElement().setPropertyString("value", ""); when SubmitCompleteEvent is called.

@UiHandler("uploadFileFormPanel")
void handleuploadFileFormPanelSubmitComplete(SubmitCompleteEvent e){
    uploadFile.getElement().setPropertyString("value", "");
    presenter.uploadCompleted(e);
}
Pedro Romano
  • 10,973
  • 4
  • 46
  • 50
Pulkit Anchalia
  • 766
  • 7
  • 8
6

Answered on the GWT forum: https://groups.google.com/d/msg/google-web-toolkit/F3FIWQOBmqo/-lnJtAbV9xUJ

The only way to clear an <input type=file> (or FileUpload widget in GWT) is to reset() the enclosing form (FormPanel). If that's not possible, then you'll have to replace the FileUpload with a newly created one (this is what I did years ago, works great)

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164