title: GWT FormPanel onSubmitComplete event not firing when downloading a file
body: <p>I created servlet to download file from a server. In GWT I created a FormPanel and I am able to download a file.</p>
  
  <p>Problem is, that I want to fire an event, when the file is ready. I tried to use onSubmitComplete event, but it isn't firing. </p>
  
  <p>I found a suggestion, to change ContetType to "text/html", but still no luck. I found, that the problem lies in writing to OutputStream - when commented out, event is fired.</p>
  
  <p>Here is my servlet code</p>
  
  <pre><code>public void handleRequest(HttpServletRequest request,
          HttpServletResponse response) throws ServletException, IOException {
      response.setContentType("text/html");
      response.setHeader("Content-Disposition", "attachment; filename=File.xls");
  
      HSSFWorkbook workbook = new HSSFWorkbook();
  
      try {
  
          workbook = fileCreator.getWorkbook();
  
      } catch (ClassNotFoundException e) {
          e.printStackTrace();
      } catch (SQLException e) {
          e.printStackTrace();
      } catch (ParseException e) {
          e.printStackTrace();
      }
  
      OutputStream out = response.getOutputStream();
      workbook.write(out);
      out.close();
      response.setStatus(HttpServletResponse.SC_OK);
      response.getWriter().print("something");
      response.flushBuffer();
  }
  </code></pre>
  
  <p>So file is downloaded successfully, but event is not triggered. Even when I just get OutputStream and close it (without writing to it), event stops working.</p>
  
  <p>When I remove whole "writing-to-output-stream" code, event works like a charm.
  Any suggestions?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here is code for FormPanel and its handlers, meby there is a problem?</p>
  
  <p>Form:</p>
  
  <pre><code>downloadFileFormPanel.setEncoding(FormPanel.ENCODING_URLENCODED);
  downloadFileFormPanel.setMethod(FormPanel.METHOD_POST);
  VerticalPanel panel = new VerticalPanel();
  panel.setWidth(UIConstatns.SIZE_100percent);
  downloadFileFormPanel.setWidget(panel);
  
  downloadFileButton = new Button(messages.EXPORT_LIMITS());
  downloadFileButton.setWidth(UIConstatns.SIZE_100percent);
  downloadFileButton.addStyleName("navigation-button");
  panel.add(downloadFileButton);
  </code></pre>
  
  <p>Handlers</p>
  
  <pre><code>private void registerExportLimitsHandler() {
  registerHandler(getView().getDownloadFileButton().addClickHandler(new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
              getView().showLoadingDialog();
              getDownloadFileForm().submit();
          }
      }));
  }
  
  private void registerFormSubmitCompleteHandler() {
      getView().getDownloadFileForm().addSubmitCompleteHandler(new SubmitCompleteHandler() {
          public void onSubmitComplete(SubmitCompleteEvent event) {
              Window.alert("download complete");
              getView().hideLoadingDialog();
          }
      });
  }
  </code></pre>