tags:

views:

36

answers:

2

Hi!

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!!

+1  A: 

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:

seanizer
A: 

Its not a problem with Ajax, if not about the image (the litle wheel indicating "loading") showed 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 refreses 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);
      }
 }
jOki
you should accept your own solution or the question will keep showing up as unanswered
seanizer