简体   繁体   English

小票执行逻辑时加载图标/弹出窗口

[英]Wicket loading icon/popup while performing logic

In my Wicket application I have a few lines of code that take some time to execute. 在我的Wicket应用程序中,我有几行代码需要花费一些时间来执行。 It would be nice, if I could show a loading icon or popup, during the time the logic is being excecuted. 如果我可以在执行逻辑的过程中显示加载图标或弹出窗口,那就太好了。 The problem is that I have no idea how to implement something like this. 问题是我不知道如何实现这样的事情。 Can someone help me with this? 有人可以帮我弄这个吗?

And the Goal is 目标

Class.java
    // Show popup or icon
    this.getData();
    // Hide popup

Have a look at AjaxLazyLoadPanel . 看看AjaxLazyLoadPanel Put the display of the stuff that takes long into an Panel and wrap it with AjaxLazyLoadPanel. 将需要很长时间的东西显示在面板中,并用AjaxLazyLoadPanel包装。

Look at this wicket wiki: 看一下这个检票口维基:

Generic Busy Indicator (for both Ajax and non-Ajax submits) 通用繁忙指示器(适用于Ajax和非Ajax提交)

If you are using ajax button/link you can use IndicatingAjaxLink and IndicatingAjaxButton both comes from wicket-extensions 如果您正在使用ajax按钮/链接,则可以使用IndicatingAjaxLinkIndicatingAjaxButton都来自wicket-extensions

<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-extensions</artifactId>
<version>${wicket.version}</version>
</dependency>

Links about custom indicators: 有关自定义指标的链接:

Customizing IndicatingAjaxLink in wicket 在检票口中自定义IndicatingAjaxLink

Is it possible to change the color of Wicket's activity indicator? 可以更改Wicket活动指示器的颜色吗?

And you can also override the css class: 您还可以覆盖css类:

span.wicket-ajax-indicator img {
  margin: 0;
  padding: 0;
  padding-left: 2px;
  display: inline;
  white-space: nowrap;
}

If you want to load a pop up that you would want to customize, then you can use a modal 如果要加载要自定义的弹出窗口,则可以使用模式

window. 窗口。 Follow the tutorial to load a modal window on click. 遵循教程以在单击时加载模式窗口。

Have whatever text you please on the destination panel. 在目标面板上输入您想要的任何文本。

In onConfigure() of modalPanel1 (destination panel), in the end add the following code: 在modalPanel1(目标面板)的onConfigure()中,最后添加以下代码:

Thread.sleep(//time average);
window.close(target);

Where target is passed as a parameter to the constructor from the ModalWindowPage.java as an object for the constructor. target作为参数从ModalWindowPage.java作为构造函数的对象传递给构造函数。

So ideally this is the change in instantiating: 因此,理想情况下,这是实例化的更改:

modal2.setContent(new ModalPanel1(modal2.getContentId(),target);

where target is the ajax link/button target. 其中target是ajax链接/按钮目标。

You can also activate it on the load of page (Click here to view the discussion) 您也可以在页面加载中激活它(单击此处查看讨论)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM