I have a weird problem using RF. I try to save a EntityProxy which has
a ManyToOne relation. Depending the order of the instructions i get a
NullPointerException or not.

Here is my code :

MyRequestContext ctx =
ClientFactory.MyRequestFactory.MyRequestContext();

// parent object
UserProxy userCreated = ctx.create(UserProxy.class);

// child object
AddressProxy address = ctx.create(AddressProxy.class);

userCreated.setAddress(address);

userCreated.setLastName("lastName");
userCreated.setFirstName("firstName");

address.setStreet("street");

Long cityId = 1l;

ctx.createInstallation(userCreated,
cityId).with("address.city").fire(new MyReceiver<UserProxy>() {
        public void onSuccess(UserProxy user) {
                user.getAddress.getCity(); //Nullpointer exception
because address is null
        }
});

If I execute the previous code i get a NPE on this instruction :
user.getAddress.getCity(); --> address is empty. When i debug the
server code i can notice that everything is persited correctly (both
AddressProxy and UserProxy). I use the .with("address.city")
instruction and i expect a non empty empty but it's not the case.

If i change the order of the lines responsible of the EntityProxy
creation like this :
// child object
AddressProxy address = ctx.create(AddressProxy.class);
// parent object
UserProxy userCreated = ctx.create(UserProxy.class);

then the line "user.getAddress.getCity();" return me a valid Address
the firts three times and an empty one the next time. I have a random
NPE.

Could you tell me if there is a specific EntityProxy creation order to
respect when using RequestFactory and entities relationship ? Same
question when filling properties ?
Is there something particular with the with() instruction ?
Why my code behave like this ?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to