问题描述
限时送ChatGPT账号..在 Wicket 页面上,我有一个图像 (AbstractDefaultAjaxBehavior.INDICATOR),它在提交时显示,然后我启动 AjaxSelfUpdatingTimerBehavior 来监视文件.
On the Wicket page I have an image (AbstractDefaultAjaxBehavior.INDICATOR) which is shown on submit and then i start a AjaxSelfUpdatingTimerBehavior to monitor a file.
现在我还有一个下载链接来下载相同的文件.但是,下载我上面提到的图像(正在旋转)后停止旋转.这个问题有解决方案吗?我是检票口的新手.请建议.
Now I also have a DownloadLink to download the same file. However after download the image which I mentioned above (which is rotating) stops rotating. Is there a solution to this issue? I am new to wicket. Please suggest.
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')");
}
推荐答案
首先,我必须承认我现在不知道您的代码可能有什么问题.这看起来与我解决你的任务的方式大不相同.
First I have to admit that I have no idea right now what could be wrong with your code. It looks rather different than how I would solve your task.
据我所知,您想要在用户点击提交按钮后动画的图像(动画 gif),对.并且它应该在满足某个条件(文件生成完成等)后停止动画.您还希望获得文件的下载链接.
As I understand you want to have a image (an animated gif) that is animated after the user hits the submit button, right. And it should stop the animation after a certain condition is met (file generation finished etc.). Also you want to have a download link for your file.
我要做的是
使用将显示的动画 gif添加一个 AjaxSelfUpdatingTimerBehavior 来检查您的文件,如果满足某个条件,它会更改图像(可能通过更改图像本身、设置图像的可见性或更改图像容器的某些 css 属性)对于文件下载,我将使用 ajax 按钮,或者如果您不应该更改任何内容,则使用为您的文件提供资源流的普通链接希望这会有所帮助.
这篇关于检票口下载链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论