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.

5 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. dengan memiliki rasa coklat permen soloco sangat cocok bisa menambah suasana romantis yang mendalam saat bercinta bersama pasangan. baca tautan . wanita membutuhkan durasi yang lama saat berhubungan badan, obat luar seperti hajar jahanam cair obat kuat original bisa mencegah terjadinya ejakulasi dini yang terlalu cepat jadi bisa menambah kepuasan dalam bercinta bersama pasangan. klik disini . satu lagi obat luar jenis cream yang sekarang ini banyak diburu seperti cream stud 007 obat kuat aman yang sekaligus dapat digunakan sebagai gel pelicin sebelum berhubungan intim agar mempermudah masuknya saat penetrasi. info selengkapnya . besar dan panjangnya ukuran alat kelamin pria bisa menambah kepuasan wanita secara maksimal dengan cara menggunakan terapi pro extender secara rutin akan mendapatkan hasil yang maksimal.

    ReplyDelete