1

In my Wicket application I have a few lines of code that take some time to execute. 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
Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57
Alex
  • 223
  • 1
  • 6
  • 21

3 Answers3

3

Look at this wicket wiki:

Generic Busy Indicator (for both Ajax and non-Ajax submits)

If you are using ajax button/link you can use IndicatingAjaxLink and IndicatingAjaxButton both comes from 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

Is it possible to change the color of Wicket's activity indicator?

And you can also override the css class:

span.wicket-ajax-indicator img {
  margin: 0;
  padding: 0;
  padding-left: 2px;
  display: inline;
  white-space: nowrap;
}
Community
  • 1
  • 1
Rangel Preis
  • 394
  • 1
  • 7
  • Thx! The IndicatingAjaxLink is working. A loading icon is shown. The only problem left is the location of the icon. I would like to show the loading icon on the button itself, or in the center of the screen. How is the location specified? – Alex Apr 16 '13 at 14:23
3

Have a look at AjaxLazyLoadPanel. Put the display of the stuff that takes long into an Panel and wrap it with AjaxLazyLoadPanel.

bert
  • 7,566
  • 3
  • 31
  • 47
  • Is something like this also possible for a button? In my application, I have a panel with a button, and the buttons performs an action that takes a few seconds (onEvent action). – Alex Apr 16 '13 at 13:29
  • Than I think the above answer by Rangel is better suited. – bert Apr 16 '13 at 13:32
0

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:

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.

So ideally this is the change in instantiating:

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

where target is the ajax link/button target.

You can also activate it on the load of page (Click here to view the discussion)

Community
  • 1
  • 1