Wicket1.5 csv生成リンク

Wicket 1.5 で動的にCSVをダウンロードさせるリンク

サンプル

import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler;
import org.apache.wicket.request.resource.ContentDisposition;
import org.apache.wicket.util.resource.StringResourceStream;


final String csvStr;
  :
  :
add(new Link<Void>("downloadCSV"){
   @Override
   public void onClick(){
      StringResourceStream stream = new StringResourceStream(csvStr,"text/comma-separated-values");
      getRequestCycle().scheduleRequestHandlerAfterCurrent(
         new ResourceStreamRequestHandler(stream)
         .setFileName("demo.csv")
         .setContentDisposition(ContentDisposition.ATTACHMENT)

      );
   }
});

----- html ---
<a wicket:id="downloadCSV">CSV download</a>