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.
What is the best way to include the file downloader(or to the browser default download folder) in the org.compiere.process?
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;
}