Hello Ernesto, Yes!!! It did the trick! Great!
Let me understand, you schedule a request handler just after the current, like in the onRequest... AjaxRequestTarget target = app.newAjaxRequestTarget(getComponent().getPage()); RequestCycle requestCycle = RequestCycle.get(); requestCycle.scheduleRequestHandlerAfterCurrent(target); So what happens with the current one. It returns nothing? Does it changes something in the request? Thank you a lot! El sáb, 20-10-2012 a las 16:08 +0200, Ernesto Reinaldo Barreiro escribió: > on the respond method of your AbstractDefaultAjaxBehavior > > On Sat, Oct 20, 2012 at 4:07 PM, Ernesto Reinaldo Barreiro < > reier...@gmail.com> wrote: > > > Try the following > > > > TextRequestHandler textRequestHandler = new > > TextRequestHandler("application/json", "UTF-8", "Your JSON HERE"); > > RequestCycle.get().scheduleRequestHandlerAfterCurrent(textRequestHandler); > > > > On Sat, Oct 20, 2012 at 4:00 PM, Gonzalo Aguilar Delgado < > > gagui...@aguilardelgado.com> wrote: > > > >> Hello, > >> > >> I was looking to some code and googling around but cannot find a > >> suitable solution for my problem. > >> > >> > >> I have an AbstractDefaultAjaxBehavior that I'm implemented the function > >> respond(AjaxRequestTarget target) like this > >> > >> --- > >> @Override > >> protected void respond(AjaxRequestTarget target) { > >> > >> > >> > >> JsonChoiceRenderer<T> jsonRenderer = new > >> JsonChoiceRenderer<T>(getChoices()); > >> > >> target.appendJavaScript(jsonRenderer.renderJsonArray(getComponent(), > >> getRenderer())); > >> > >> } > >> > >> --- > >> > >> But this is not a JSON response when it is called from javascript. I > >> want to respond with an application/json response. > >> > >> I saw something like: > >> > >> RequestCycle requestCycle = RequestCycle.get(); > >> requestCycle.getResponse().setCharacterEncoding("UTF-8"); > >> requestCycle.getResponse().setContentType("application/json;"); > >> > >> But it means that I have to override the final void onRequest() of the > >> AbstractAjaxBehavior class, but this is final so I cannot. > >> > >> > >> What's the best way to do it with newer versions of wicket? > >> > >> > >> Thank you a lot in advance. > >> > > > > > > > > -- > > Regards - Ernesto Reinaldo Barreiro > > Antilia Soft > > http://antiliasoft.com > > > > > >