Wicket: reload AjaxLazyLoadPanel automatically

2019-07-13 11:47发布

I have a page with a form. Using the data from the form I get information from a BBDD and I displayed in a panel using Ajax.

Now I was trying to use a AjaxLazyLoadPanel, because some of the query in the BBDD are heavy. The problem i have is after the first load of AjaxLazyLoadPanel, i dont know how to reload it with the new content (a new search).

Any advice??

Thanks!!

标签: java ajax wicket
2条回答
We Are One
2楼-- · 2019-07-13 12:13

I have not worked with AjaxLazyLoadPanel, but the generic approach to periodically updating a component is attaching an AjaxSelfUpdatingTimerBehavior:

add(new AjaxLazyLoadPanel("myPanel"){
    // implementation here
}
.setOutputMarkupId()
.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(2))));

Or, if that does not work, at the behavior to a different component and let the AjaxRequestTarget add the AjaxLazyLoadPanel (you might have to attach the AjaxLazyLoadPanel first).


Here are a few relevant links about wicket and AJAX:

查看更多
戒情不戒烟
3楼-- · 2019-07-13 12:14

It's not a problem with Ajax, it's about the image (the little wheel indicating "loading") that shows the first time the AjaxLazyLoadPanel is loaded.

I think I've found a solution:

Add the AjaxLazyLoadPanel in a WebMarkupContainer and in the ajax button that refreshes the content:

 // lazy is the WebMarkupContainer
 @Override
 protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

      lazy.replace(new AjaxLazyLoadPanel("lazyLoadSearch") {
           @Override
           public Component getLazyLoadComponent(String id) {
                return new SearchPanel(id, rep, searchString, typeOfSearch);
           }
      });

      if (target != null) {
           target.addComponent(lazy);
      }
 }
查看更多
登录 后发表回答