wicket测试发送ajax请求

I've encountered some days ago the following Problem: I have a Page.class with 2 panels. Panel 1 for example gets a click on a Datatable.

@Override
protected void onRowClick(final AjaxRequestTarget target, final Item<Template> item) {
    this.send(this.getPage(), Broadcast.BREADTH, new CustomAjaxEvent(target));

}

Custom Ajax Event is holding the RequestTarget, and will be used later to identify the triggered event in another panel.

Now in my second panel I've the following method:

@Override
public void onEvent(IEvent<?> event) {
    Object payload = event.getPayload();

    if(payload instanceof CustomAjaxEvent){
        ((CustomAjaxEvent)payload).target.add(this)
    }
    super.onEvent(event);
}

Now I'm going to test this stuff.. (following code is in testClass)

panel.send(panel.getPage(),
     Broadcast.BREADTH,
     new CustomAjaxEvent(RequestCycle.get().find(AjaxRequestTarget.class)));

Nullpointer exception occurs on "target.add(this)" from codeblock 2

Of course it is null.. There is no request.

The question is how can I trigger the second codeblock? Access to panel 1 is not given, because I test panel 2 only. Which implies, that I can't click a row in the dataTable and let panel 1 trigger the event.

EDIT: I'm using wicket 6.18

查看全部
weixin_33749242
weixin_33749242
2015/11/10 13:41
  • request
  • ajax
  • events
  • 点赞
  • 收藏
  • 回答
    私信

1个回复