-
FEATURED COMPONENTS
First time here? Check out the FAQ!
When user click on button local path file will be download with browser. i don't want to use ZScript.
I Got My Complete Solution
@Command("onView")
public void doView() {
logger.info("Clicked doView button");
FileInputStream inputStream;
try {
File dosfile = new File(dosPath);
if (dosfile.exists()) {
inputStream = new FileInputStream(dosfile);
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(dosfile), dosfile.getName());
} else
showInfo("Sorry, but the DosPath is Invalid");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
You can use zk Filedownload.save feature. Please have a look at this demo link text. I am useing in my code like
ByteArrayOutputStream baos = new ByteArrayOutputStream();
excel_workbook.write(baos);
if (baos.size() > 0) {
Filedownload.save(baos.toByteArray(), "application/vnd.ms-excel",
fileName);
}
I appreciate that you do not want to use ZScript.
Senthilchettyin ( 2013-01-24 11:56:38 +0800 )editWe also disable Zscript in our project if developer will use Zscript in future our code will be unmanageable like our previous project Jsp+JS.
sjoshi ( 2013-01-24 12:05:55 +0800 )edit