Sure:

<li>
                  
                      
                        CSV
                      
                                   
</li>

   @SuppressWarnings("unused")
   @Component(parameters = {"event=clicky", "defer=false"})
   private LinkSubmit link;
   
   @OnEvent(value="submit")
   Object doExport() throws Exception
{
       ByteArrayOutputStream baos = //get the csv
       return new CsvStreamResponse(baos, other params);
}

      private CsvStreamResponse(ByteArrayOutputStream baos, other params)
      {
         this.inputStream = new ByteArrayInputStream(os.toByteArray());
         //other initiialization
      }

      @Override
      public void prepareResponse(Response response)
      {
         try
         {
            response.setHeader("Content-Disposition", "attachment;
filename=" + this.fname + ".csv");
            response.setContentLength(this.inputStream.available());
         } 
         catch (IOException e)
         {
         }
      }

      @Override
      public String getContentType()
      {return "application/csv";}

      @Override
      public InputStream getStream() throws IOException
      {return this.inputStream;}

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/StreamResponse-onSuccess-does-not-stream-back-data-tp4759347p4760318.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to