Filedownload issue in ZK Web view

454 views
Skip to first unread message

Saj

unread,
Jun 11, 2015, 6:56:37 AM6/11/15
to idem...@googlegroups.com
Hi all,

I am trying to download a file, which is a result of a process(written in org.compiere.process). The jnlp client installation is working properly with JFileChooser. The same code always popup the file chooser in server machine. 

So for having the feature in web view, I have integrated the  jar files --- zcommon.jar, zk.jar, zul.jar, zhtml.jar--- to the base(and added in build order too) . But I am getting a Null Pointer with the code: return _exec.get(); in method 'getCurrent()' in org.zkoss.zk.ui.Executions. Desktop instance is null in this case.

Please correct me if I am trying wrong. 
What is the best way to include the file downloader(or to the browser default download folder) in the org.compiere.process?

The following is my save code for Swing and ZK Web

public boolean saveFile() throws IOException
 {
  DateTimeFormatter fmt = DateTimeFormat.forPattern("EEE, dd MMM yyyy");
  int returnValue = 0; 
  File inputFile = File.createTempFile("SalarySheet_", ".xls");
  File file = File.createTempFile("sample", ".pdf", new File("E:\\"));
  
  if (Ini.isClient())  //Check whether it is ZK or Swing
  {
   JFileChooser chooser = new JFileChooser();
   chooser.setDialogTitle("Save Log File as");
   chooser.setSelectedFile(inputFile);
   returnValue = chooser.showSaveDialog(null);
   if (returnValue == 0) 
   {
    String path = chooser.getSelectedFile().getAbsolutePath();
    File out = new File(path);
    FileOutputStream fileOut = new FileOutputStream(out);
    fileOut.close();
   }
  }
  else   
  {
   FileOutputStream fileOut = new FileOutputStream(inputFile);
   fileOut.close();
   AMedia media = new AMedia(inputFile.getName(), null, "application/octet-stream", inputFile, true);
   Filedownload.save(media, inputFile.getName()+".xls");  //ZK Filedownload
   
  }  
  return returnValue == 0 ? true : false;
 }

Carlos Antonio Ruiz Gomez

unread,
Jun 12, 2015, 6:55:45 PM6/12/15
to idem...@googlegroups.com
To download a file resulting from a process you just need to add in your process something like:

        if (processUI != null)
            processUI.download(theFileToExport);

See PackoutProcess or ImportCSVProcess for example.

Regards,

Carlos Ruiz
Reply all
Reply to author
Forward
0 new messages