Hi all wicket pros out there,
I would like to get extra parameter I added to the AjaxRequest in the respond(AjaxRequestTarget target) method of a AbstractDefaultAjaxBehaviour.
I build the Wicket.Ajax.get(...) call by myself and I could manage that the respond(AjaxRequestTarget target) method of the AbstractDefaultAjaxBehaviour is invoked, but I get stock in how to get the extra parameters I added in my js call.
So here the code what I'm doing:
js that is called onSelect:
Wicket.ajax.get({'u':'callbackUrl','c':'componetId', 'ep':{'objectId':'OBJECT_ID'}});
java snippet of the AbstractDefaultAjaxBehaviour:
onSelectBehavior = new AbstractDefaultAjaxBehavior(){
@Override
protected void respond(AjaxRequestTarget target) {
//here I want to get the OBJECT_ID I added in the Wicket.Ajax.get call above
}
};
The respond() method is invoked as expected, but I don't know how to get the OBJECT_ID. Actually I'm not sure at all if I added the extra parameter in the right way to the wicket.ajax.get call.
In Wicket 1.4 I added the extra parameters as a url query string like ajaxCallUrl...?objectId=OBJECT_ID
and in respond() I got them back from the RequestCycle RequestCycle().get().getRequest().getParameter('objectId')
If anyone could give me a hint, I would appreciate it :) Thanks in advance, Ronny
Your approach is correct. You should be able to get the parameter like this:
@Override
protected void respond(AjaxRequestTarget target)
{
getRequest().getRequestParameters().getParameterValue("objectId");
}
See my answer to this question for passing parameters directly from Wicket without constructing the ajax call yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With