Q5:my code for wicket1.5 as follow:
final Link lnkExport = new Link("export") {
public void onClick() {
Shop shop = shopService.read(shopId);
// temporarily switch off paging of results
final JxlExportShop jxlExportShop = new
JxlExportShop(shop);
getRequestCycle().scheduleRequestHandlerAfterCurrent(new
IRequestHandler() {
@Override
public void detach(IRequestCycle
requestCycle) {
}
@Override
public void respond(IRequestCycle
requestCycle) {
try {
Shop shop =
shopService.read(shopId);
String fileName =
shop.getShopCity() + "_" + shop.getShopName() +
"_version_" + shop.getShopVersion() + ".xls";
fileName = new
String(fileName.getBytes("gb2312"), "iso8859-1");
HttpServletResponse
httpResponse =
(HttpServletResponse)requestCycle.getResponse().getContainerResponse();
httpResponse.setContentType( "application/vnd.ms-excel" );
httpResponse.setHeader("Content-disposition", "attachment; filename="
+ fileName );
jxlExportShop.exportToExcel(httpResponse.getOutputStream());
} catch (Exception e) {
throw new
RuntimeException(e);
}
}
});
}
};
-----
http://www.517wm.com
外卖订餐分享工具
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/how-to-get-HttpServletRequest-in-wicket-1-5-tp3798272p3832287.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]