in Wicket 1.x I used an AjaxEventBehavior to place a CallBackScript that delivers me the mouse coordinates. This is what I did: (getEventX() and getEventY() are JavaScript Functions)
myObject.add(new AjaxEventBehavior("onClick") {
private static final long serialVersionUID = 1L;
@Override
protected CharSequence getCallbackScript() {
return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl()
+ "&x=' + getEventX(this, event) + '&y=' + getEventY(this, event)");
}
@Override
protected void onEvent(AjaxRequestTarget target) {
final Request request = MyPage.this.getRequest();
final IRequestParameters parameters = request.getRequestParameters();
final int x = Integer.parseInt(parameters.getParameterValue("x").toString("0"));
final int y = Integer.parseInt(parameters.getParameterValue("y").toString("0"));
That worked quite well. But I don't get how to do this with Wicket 6.x
I do understand, that the way the Ajax link is working was changed. So I tried to use getCallBackUrl in the same way than before. But that did not work.
public CharSequence getCallbackUrl() {
final CharSequence callBackUrl = super.getCallbackUrl();
return callBackUrl + "&x=' + getEventX(this, event) + '&y=' + getEventY(this, event)";
}
When I take a look at the generated HTML I can see the ajax link looks like this:
Wicket.Ajax.ajax({"u":"../page?5-2.IBehaviorListener.2-cityMap&x=' + getEventX(this, event) + '&y=' + getEventY(this, event)","e":"click","c":"cityMap","i":"id29--ajax-indicator"});;
Looks good, but it does not work.
I am pretty sure, I am doing something wrong since wicket 6 but I dont know how to do it the right way.
Any suggestions are greatly appreciated.
cheers Reinhard