我盡我所能來描述我的情況。 我的檢票站包含列表檢票組件,其中每個列表元素都有另一個列表。最低級別列表中的每個元素都有一個jax wicket鏈接來下載某個文件。所有這些工作正常。我習慣了這個AjaxBehaviour。此行爲的方法startDownload在鏈接onClick方法內調用。這種行爲另一個請求後的檢票口觸發請求
public void startDownload(AjaxRequestTarget target) {
target.appendJavaScript("window.location.href='" + getCallbackUrl() +"'");
}
方法onRequest是:
@Override
public void onRequest() {
IRequestHandler fileTarget = new IRequestHandler() {
@Override
public void respond(IRequestCycle requestCycle) {
if (null != file) {
try {
FileInputStream inputStream = new FileInputStream(file);
WebResponse resp = (WebResponse) requestCycle.getResponse();
resp.setAttachmentHeader(fileName);
String contentType = FileUtils.getFileType(fileName);
if (contentType != null) {
resp.setContentType(contentType);
}
resp.setHeader("Pragma", "anytextexeptno-cache");
resp.setHeader("Cache-Control", "max-age=0");
Streams.copy(inputStream, requestCycle.getResponse().getOutputStream());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
現在我需要重新加載模式和下載後的文件操作刷新頁面某些組件。我嘗試在代碼調用startDownload方法後,將整個頁面添加到方法onclick中的AjaxRequestTarget。重新加載頁面正常工作,但文件下載窗口不顯示。
我認爲我必須在其他單獨的請求中重新加載頁面(也許我錯了?),因爲在這個請求中我稱之爲'window.location.href = ....',但是我不`我知道如何執行第二次請求重新加載頁面。
有人有些想法我做錯了嗎?我該如何解決我的問題?
沒有意義,在第一做一個Ajax請求,然後重新加載整個頁面。 – 2015-04-02 15:26:34