我想在单击按钮后下载 csv 文件,而不使用下载链接。通过下载链接我可以做到这一点:
DownloadLink link = new DownloadLink(wicketID, new AbstractReadOnlyModel<File>() {
private static final long serialVersionUID = 1L;
@Override
public File getObject() {
File tempFile;
try {
tempFile = File.createTempFile("test", ".csv");
InputStream data = new ByteArrayInputStream("some data for elli".getBytes());
Files.writeTo(tempFile, data);
} catch (IOException e) {
throw new RuntimeException(e);
}
return tempFile;
}
}
).setCacheDuration(Duration.NONE).setDeleteAfterDownload(true);
return link;
}
如何在普通 wicket 按钮的 onSubmit
方法中执行此操作?我正在使用 wicket 6。
最佳答案
已在 Wicket jQuery UI 问题跟踪器中回答:https://github.com/sebfz1/wicket-jquery-ui/issues/180#issuecomment-119539231
关于java - Wicket 口中带有文件下载的提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31290667/