Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get extra parameter from AjaxRequest wicket 6

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

like image 497
rontron Avatar asked Nov 02 '12 16:11

rontron


1 Answers

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.

like image 62
Thomas Avatar answered Oct 12 '22 07:10

Thomas