3/14/2008

File download in Click Framework

Click Framework provides FileField to upload file, however Click does not provide any support for file downloading. I made AbstractDownloadPage to download file.

Usage:

 public class SampleDownloadPage extends AbstractDownloadPage {
  public SampleDownloadPage(){
    setFileName("sample.txt");
    setContents(SampleDownloadPage.class.getResourceAsStream("sample.txt"));
  }
} 

This page class does not have a template because response is written by this class. So auto-mapping does not work for file download pages. The extended page class have to be registered to click.xml.

0 件のコメント: