6

in my current project i've faced a problem of customizing IndicatingAjaxLink in wicket, is there any solution to change standart gif image to my own? For example we have following listeneer

   add(new IndicatingAjaxLink("closeReceivedBillspanel") {
            public void onClick(AjaxRequestTarget art) {
                  // some timeconsuming calculations
           }
   });

as user clicks this link, the gif with loading appears, and i want to change this gif, is there any solution for this problem?

ilya.stmn
  • 1,604
  • 5
  • 23
  • 41

2 Answers2

13

Have your page implements the IAjaxIndicatorAware interface

public class BasePage extends WebPage implements IAjaxIndicatorAware {   

 public BasePage(final PageParameters parameters) {
    // Home link
    AjaxLink<Page> homeLink = new AjaxLink<Page>("homeLink") {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClick(AjaxRequestTarget target) {
        setResponsePage(HomePage.class);
      }
    };
    add(homeLink);
  }

  @Override
  public String getAjaxIndicatorMarkupId() {
    return "indicator";
  }

This way, you can set, in the html, any image you want to display when the loading appears by changing the image in the "img" tag

<div id="indicator" style="display: none;">
 <div class="indicator-content">
  Please wait... <wicket:link><img src="images/loading.gif" width="16" height="16" alt="loading" /></wicket:link>
 </div>
</div>
jrochette
  • 1,117
  • 5
  • 22
2

Create yoru own custom class like, (copy whats inside IndicatingAjaxLink and update)

   public class MyIndicatingAjaxLink<T> extends AjaxLink<T> implements IAjaxIndicatorAware {
         private final MyAjaxIndicatorAppender indicatorAppender = new MyAjaxIndicatorAppender();    
    .
    //rest of the code is same as IndicatingAjaxLink class
    .
    }

Also you need a custom AjaxIndicatorAppender within your customIndicatingAjaxLink and you need to override below method of indicatorAppender to return path of your custom image

protected CharSequence getIndicatorUrl()
fmucar
  • 14,361
  • 2
  • 45
  • 50