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

Reply via email to