Hi,

It seems Retrofit starts a Thread ('in thread "Retrofit-Idle"') to make the
requests.
A RequestCycle is exported as a ThreadLocal only in the web container
worker threads.
See ComponentRenderer#renderPage() and WicketFilter  for examples how to
construct RequestCycle.

Martin Grigorov
Wicket Training and Consulting


On Wed, May 7, 2014 at 8:49 PM, Noven <noven_...@yahoo.com> wrote:

> Hi all,
>
> I am experimenting with retrofit (http://square.github.io/retrofit/) rest
> client and have issue that I can't fix.
>
> I have a form that on submit will call the wicket-rest service.
>
> form.add(new AjaxButton("submit") {
>             @Override
>             protected void onSubmit(final AjaxRequestTarget target,
> Form<?> form) {
>
> getWicketApplication().getPersonService().createPerson((PersonPojo)
> form.getModelObject(), new Callback<PersonPojo>() {
>
>                     @Override
>                     public void success(PersonPojo t, Response rspns) {
>                         info("Success creating person");
>
>                         target.add(feedback);                 // error
> from here
>                     }
>
>                     @Override
>                     public void failure(RetrofitError re) {
>                         error("Error creating person");
>                         target.add(feedback);
>                     }
>                 });
>             }
>         });
>
>
> I am able to submit the form successfully..  but unable to call the
> target.add(feedback);
>
> Here is the logs :
>
> INFO  - PersonForm                 - Success creating person
> Exception in thread "Retrofit-Idle"
> org.apache.wicket.WicketRuntimeException: No RequestCycle is currently set!
> at org.apache.wicket.Component.getRequest(Component.java:1818)
> at org.apache.wicket.markup.html.WebPage.dirty(WebPage.java:318)
> at org.apache.wicket.Page.dirty(Page.java:248)
> at org.apache.wicket.Page.componentStateChanging(Page.java:937)
> at org.apache.wicket.Component.addStateChange(Component.java:3542)
> at org.apache.wicket.Component.info(Component.java:2008)
> at com.restclient.form.PersonForm$1$1.success(PersonForm.java:62)
> at com.restclient.form.PersonForm$1$1.success(PersonForm.java:57)
> at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
> at retrofit.Utils$SynchronousExecutor.execute(Utils.java:114)
> at retrofit.CallbackRunnable.run(CallbackRunnable.java:43)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at retrofit.Platform$Base$2$1.run(Platform.java:94)
> at java.lang.Thread.run(Thread.java:744)
>
> I guess there's something I missed here, The RequestCycle. I just don't
> know what to do next.
>
> Please help.
>
> Regards,
> Noven

Reply via email to