the proper approach is to push a new request target into the request cycle,
see DownloadLink

-igor


On 1/3/07, Frank Silbermann <[EMAIL PROTECTED]> wrote:

 In my project, I have a button that lets the user download the contents
of a datatable in a form that MSExcel can interpret:
  Button button = new Button("excelExport") {
    protected void onSubmit() {
      getRequestCycle().setRequestTarget(new
ComponentRequestTarget(dataTable));
      WebResponse wr=(WebResponse)getResponse();
      wr.setContentType( "excel/ms-excel; name=myFilename.xls" );
      wr.setHeader("content-disposition", "attachment;filename=
myFilename.xls");
    }
  };

Suppose I want the button to download a text file containing some
arbitrary text (not necessarily the contents of a DataTable).  Would I do
something like this?

  Button button = new Button("textfileExport") {
    protected void onSubmit() {

      StringResponse response = new StringResponse();
      response.write(
              "Whatever I want contained in the output text file..."
      );
      getRequestCycle().setResponse(response);

      WebResponse wr=(WebResponse)getResponse();
      wr.setContentType( "text/plain; name=myFilename.txt" );
      wr.setHeader("content-disposition", "attachment;filename=
myFilename.txt");
    }
  };

If not, what is the proper approach?


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to