Thursday, May 30, 2013

Using nested arrays of complex types in GWT

Java's code:

public class Person {
   private String name;
   private int[] luckyDays;

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public int[] getLuckyDays() {
      return luckyDays;
   }

   public void setLuckyDays(int[] luckyDays) {
      this.luckyDays = luckyDays;
   }

}


public class Family {
   private Person[] persons;

   public Person[] getPersons() {
      return persons;
   }

   public void setPersons(Person[] persons) {
      this.persons = persons;
   }

}

in GWT will be (only getters for deserializer):


import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;

public class PersonClient extends JavaScriptObject {

   protected PersonClient() {}

   
   public final native String getName() /*-{
      return this.name;

   }-*/;

   public final native JsArrayNumber
getLuckyDays() /*-{
      return this.
luckyDays;
   }-*/;


}

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;

public class FamilyClient extends JavaScriptObject {


   protected FamilyClient() {} 


   public final native JsArray<PersonClient> getPersons() /*-{
      return this.
persons
   }-*/;


}

Example how to use it:


JsArrayString names = Properties.createArray().cast();
s.push("Foo");

Properties properties = Properties.create();
properties.setNumber("from", from.getValue().getTime());
properties.setNumber("to", to.getValue().getTime());
properties.set("names", s);


GQuery.getJSON("/getPersonsByNames.json", $$(params), new Function() {

   @Override
   public void f() {



      JavaScriptObject response = (JavaScriptObject) this.getDataObject();
     
FamilyClient family = response.cast();

      for (int i = 0; i <
family.getPersons().length(); i++) {
         
PersonClient person = family.getPersons().get(i);
         ...
      }
   }
}




Saturday, May 11, 2013

Rent a car in Dubai


  1. Book car. I used http://www.economycarrentals.com/ the day before arrival
  2. Get international driving license: http://www.gibdd.ru/gosuslugi/reg/exm/ 
  3. In Dubai airport find your deck (mine was Nationale, the name is written in order blank)
  4. Pay in place with VISA: rent price + deposit (this will be on hold)
  5. Take keys and move to 3rd line outside the airport - there you'll get car
  6. Examine car on damage and you are done.
Hint:
  • use parking. It's really cheap while penalty is too high
  • use payed roads. Minus 20 min to reach the place