Wicket:自动重新加载AjaxLazyLoadPanel

时间:2010-08-25 10:27:02

标签: java ajax wicket

我有一个带有表单的页面。使用表单中的数据,我从BBDD获取信息,并使用Ajax在面板中显示。

现在我试图使用AjaxLazyLoadPanel,因为BBDD中的一些查询很重。我遇到的问题是在第一次加载AjaxLazyLoadPanel之后,我不知道如何使用新内容重新加载它(新的搜索)。

有什么建议吗?

谢谢!

2 个答案:

答案 0 :(得分:6)

我没有使用过AjaxLazyLoadPanel,但定期更新组件的通用方法是附加AjaxSelfUpdatingTimerBehavior

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

或者,如果这不起作用,则在对其他组件的行为中,让AjaxRequestTarget add the AjaxLazyLoadPanel(您可能必须先附加AjaxLazyLoadPanel)。


以下是关于wicket和AJAX的一些相关链接:

答案 1 :(得分:2)

这不是Ajax的问题​​,它是关于第一次加载AjaxLazyLoadPanel的图像(指示“加载”的小轮)。

我想我找到了一个解决方案:

在WebMarkupContainer和ajax按钮中添加AjaxLazyLoadPanel以刷新内容:

 // 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);
      }
 }