wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ernesto Reinaldo Barreiro <reier...@gmail.com>
Subject Re: JSON response in wicket >= 6.0.0
Date Sat, 20 Oct 2012 14:08:36 GMT
on the respond method of your AbstractDefaultAjaxBehavior

On Sat, Oct 20, 2012 at 4:07 PM, Ernesto Reinaldo Barreiro <
reiern70@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 <
> gaguilar@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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message