Author Topic: JFileChooser downloading to AjaxSwing server not Client  (Read 6702 times)

m2med

  • Newbie
  • *
  • Posts: 17
    • View Profile
JFileChooser downloading to AjaxSwing server not Client
« on: August 27, 2015, 03:01:59 PM »
Here is the code we are using to open a JFileChooser
Code: [Select]
FileInputStream in;
try {
  in = new FileInputStream(reportPath.getPath());

  JFileChooser chooser = new JFileChooser();
  chooser.setSelectedFile(new File("reportDownload.pdf")); // user will see this name during download
               
  if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(null)) {
    try {
      TraceMgr.trace("URL: " + chooser.getSelectedFile(), 1);
               
      FileOutputStream out = new FileOutputStream(chooser.getSelectedFile());
      int outBye = 0;
      while ((outBye = in.read()) != -1) {
        out.write(outBye);
      }
      in.close();
      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
} catch (IOException e1) {
  e1.printStackTrace();
}

The file is saved inside AjaxSwing/tomcat/webapps/ajaxswing/temp/<numbers>/reportDownload.pdf. and is never streamed to the browser for download.

m2med

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: JFileChooser downloading to AjaxSwing server not Client
« Reply #1 on: August 27, 2015, 03:03:50 PM »
The TraceMgr statement claims it is running inside the AWTEventQueue thread

Support Team

  • Administrator
  • Hero Member
  • *****
  • Posts: 1074
    • View Profile
Re: JFileChooser downloading to AjaxSwing server not Client
« Reply #2 on: August 31, 2015, 02:58:18 PM »
Could you attach all the log files?