Monday, April 30, 2012

GWT RequestFactory and Phonegap

After being asked a lot of times if RequestFactory works with Phonegap, I finally decided to write my answer down.

The short answer is yes, but you need to do one thing.

If you are writing a mobile website with mgwt it works out of the box, of course!
This only applies if you are building apps with gwt-phonegap and RequestFactory as your RPC mechanism.

By default RequestFactory knows the url of your server (the script got loaded from there), but if your script runs inside an app on a phone, it does not know your server. 
To fix this you need to set the RequestTransport for your Factory and give it the url, which would look something like this:


EmployeeRequestFactory factory = GWT.create(EmployeeRequestFactory.class);

DefaultRequestTransport requestTransport = new DefaultRequestTransport();
if(phoneGap.isPhoneGapDevice()){
 requestTransport.setRequestUrl("http://yourserver/rf-servlet");
}
factory.initialize(eventBus, requestTransport);


This is actually all you need to do. This is much easier if you compare it to GWT RPC and Phonegap.
Because it is much harder to configure GWT RPC for Phonegap there are utility methods in GWT Phonegap.

8 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. regards,
    I use GWT and GWT-phonegap in a project.
    An example of this post, I've tried and does not work.

    ReplyDelete
  3. You can feel free to examine this iphone spy app and test in on your own device.

    ReplyDelete
  4. like this ,we can use the good things, to help you,if we can do it ,we should do much things to help others people . we can design the top tube phone bags, and the top tube bike bags, if we like this, we should use the good things,to do it, we have the best top tube bags ,and we have the bicycle top tube bag, the cycling top tube bags, like me .we can use the waterproof top tube bags, the bike tube bags . thank you!

    ReplyDelete
  5. Here are some tips for your computer that you can watch on DVD.
    Would you like to make your own film?
    Or do you want to burn this series to DVD sooner or later on your computer?
    Whatever you want to see, Wondershare DVD Writer will do it all.
    In fact, to win (according to Wondershare DVD Carrier Windows 10), drag your favorite movie onto your DVD burner, set the entertainment,
    and click the back button.
    free Download Link is here:
    https://softserialskey.com/wondershare-dvd-creator-crack/

    ReplyDelete
  6. Event space at this resort measures square toes and includes a convention center. A on line casino, a 24-hour fitness center, and multilingual workers are additionally featured at Live Casino & Hotel - Philadelphia. Smoking is 1xbet korea allowed in designated areas at this three.5-star Philadelphia resort.

    ReplyDelete
  7. Typically, when a phone is incompatible with a IoT SIM Card purchased overseas, it becomes unusable for making calls, thereby rendering it of little value. It is important to exercise caution in this regard. Please ensure that your phone is capable of reading the card.

    ReplyDelete