Re: Wicket rest and retrofit rest client

2014-05-16 Thread Sven Meier

Hi,

Retrofit callbacks are invoked asynchronously. Once #success() is 
called, the Wicket response is probably written already.


You can't/shouldn't do anything related to Wicket in a non-request thread.

Regards
Sven

On 05/07/2014 07:49 PM, Noven 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() {

 @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



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Wicket rest and retrofit rest client

2014-05-15 Thread Noven
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() {

                    @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

Re: Wicket rest and retrofit rest client

2014-05-11 Thread Martin Grigorov
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  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() {
>
> @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