在Wicket頁面上,我有一個圖像(AbstractDefaultAjaxBehavior.INDICATOR),它在提交時顯示,然後我啓動一個AjaxSelfUpdatingTimerBehavior來監視文件。Wicket下載鏈接
現在我還有一個DownloadLink來下載同一個文件。然而,在下載之後,我上面提到的(正在旋轉的)圖像停止旋轉。有沒有解決這個問題的方法?我是新來的檢票口。請建議。
public LoggingPage() {
Form<Void> form;
this.add(form = new Form<Void>("resourceForm") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit() {
submit();
}
});
add(new DownloadLink("downloadButton", new AbstractReadOnlyModel<File>()
{
private static final long serialVersionUID = 1L;
@Override
public File getObject()
{
File file;
try
{
file = new File(LoggingPage.this.fileDetail.getLocation());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
return file;
}
}));
}//cons ends
private void submit() {
if (this.serverDetail != null && this.fileType != null && this.fileDetail != null)
{
if (this.fileViewer != null)
{
this.repeater.removeAll();
}
File file = new File(this.fileDetail.getLocation());
file = new File("C:/ueshome/logs/safe.log");
this.fileViewer = new FileViewer(file);
this.fileViewer.startTailing();
log.debug("load of allLog: " + this.fileViewer.getOldLog());
buildItem(this.fileViewer.getOldLog().getLog().toString());
this.container.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1))
{
@Override
protected void onPostProcessTarget(final AjaxRequestTarget target)
{
target.appendJavascript("$('#container').scrollTop(999999999)");
log.debug("onPostProcessTarget: " + LoggingPage.this.fileViewer.hashCode() + "at: " + System.currentTimeMillis());
final FileAttributes fileAttributes = LoggingPage.this.fileViewer.getNewLog();
String newLog = fileAttributes.getLog().toString();
log.debug("nextlog inside load()");
if (newLog != null && newLog.trim().length() > 0)
{
log.debug("~~~~~~~~~~~~~~~~~~~~````*****:" + newLog);
log.debug("String.valueOf(fileAttributes.getSize()))~~~~~~~~~~~~~~~~~~~~````*****:" + String.valueOf(fileAttributes.getSize()));
log.debug("String.valueOf(fileAttributes.getLastModified()): " + String.valueOf(fileAttributes.getLastModified()));
if (LoggingPage.this.repeater.getSizeInBytes() >= logSize)
{
LoggingPage.this.repeater.removeAll();
}
Component item = buildItem(newLog);
target.prependJavascript(String.format(
"var item=document.createElement('%s');item.id='%s';Wicket.$('%s').appendChild(item);",
"div", item.getMarkupId(), LoggingPage.this.container.getMarkupId()));
// LoggingPage.this.imgContainer.setVisible(true);
// target.addComponent(LoggingPage.this.imgContainer);
target.addComponent(item);
target.appendJavascript("$('#fileAttributesContainer').show(); ");
target.appendJavascript("$('#container').scrollTop(999999999)");
target.appendJavascript("$('#imageContainer').show(); ");
}
else
{
target.appendJavascript("$('#fileAttributesContainer').show(); ");
target.appendJavascript("$('#container').scrollTop(999999999)");
target.appendJavascript("$('#imageContainer').show(); ");
}
target.appendJavascript("alert('You are in Ajax Self')");
}
你能舉一個你的代碼樣本嗎? – magomi 2012-03-21 06:45:07
我已添加示例代碼。感謝您的快速回復。 – user1521828 2012-03-21 18:41:03
將來,在添加代碼時,只需編輯您的問題,而不是將它發佈在答案中。 – Wilduck 2012-03-22 14:30:46