As some of you may know I posted a very popular blog post about a year ago about how to get Phonegap and GWT RPC working together.
A few weeks ago John Gentillin brought the issue up again on the mgwt user group.
He rightly suggested that this could be fixed by just changing the client and without touching the server at all. So today I decided to revisit the issue and see if I can find a nice way to handle it on the client.
To fix this you need some basic knowledge of how GWT RPC works on the client.
The compiler generates some classes around the RPC interface which do the actual communication.
We need to do two things:
- set the url for the entry point
- set the url for the gwt module base
Both parameters are passed with our request and help the server code find the serialization policy. With gwt-phonegap 1.7 I decided to introcude a utility method that handles all those things directly on the client. You just pass in your service, your module url (where you GWT app is deployed) and the relative path to your service.
The code would look like this:
GreetingServiceAsync service = GWT.create(GreetingService.class); PhonegapUtil.prepareService(service, "http://www.yourserver.com/", "greet");
If you want to see how this is implemented take a look here: PhonegapUtilImplDevice.java
There is also an article on RequestFactory & Phonegap.