add(new Link("exportToXml") {
public void onClick() {
getRequestCycle().setRequestTarget(new IRequestTarget() {
public void respond(RequestCycle requestCycle) {
WebResponse r = (WebResponse) requestCycle.getResponse();
r.setAttachmentHeader("jtrac-export.xml");
ItemUtils.writeAsXml(itemSearch, getJtrac(), new OutputStreamWriter(r.getOutputStream()));
}
public void detach(RequestCycle requestCycle) {
}
});
}
});
//========================== EXCEL EXPORT ==============================
add(new Link("exportToExcel") {
public void onClick() {
// temporarily switch off paging of results
itemSearch.setPageSize(-1);
final ExcelUtils eu = new ExcelUtils(getJtrac().findItems(itemSearch), itemSearch);
// restore page size
itemSearch.setPageSize(pageSize);
getRequestCycle().setRequestTarget(new IRequestTarget() {
public void respond(RequestCycle requestCycle) {
WebResponse r = (WebResponse) requestCycle.getResponse();
r.setAttachmentHeader("jtrac-export.xls");
try {
Map<Name, String> labels = BasePage.getLocalizedLabels(ItemListPanel.this);
eu.exportToExcel(labels).write(r.getOutputStream());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void detach(RequestCycle requestCycle) {