5

How to download file in zk [closed]

asked 2013-01-24 11:00:37 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

updated 2013-01-24 11:02:37 +0800

When user click on button local path file will be download with browser. i don't want to use ZScript.

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by sjoshi
close date 2013-02-08 06:39:33

Comments

1

I appreciate that you do not want to use ZScript.

Senthilchettyin ( 2013-01-24 11:56:38 +0800 )edit
1

We 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

3 Answers

Sort by ยป oldest newest most voted
3

answered 2013-01-24 11:54:23 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

updated 2013-01-24 11:54:50 +0800

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();
        }
    }
link publish delete flag offensive edit
2

answered 2013-01-24 11:15:38 +0800

psingh gravatar image psingh flag of India
963 8

updated 2013-01-24 11:16:30 +0800

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);
        }
link publish delete flag offensive edit
0

answered 2013-01-24 11:06:31 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

you took a look at this link? link text

link publish delete flag offensive edit

Question tools

Follow
2 followers

RSS

Stats

Asked: 2013-01-24 11:00:37 +0800

Seen: 190 times

Last updated: Jan 24 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More