Saturday, April 27, 2013

Re: Entity not persisted, using JDO,RequestFactory.



On Friday, April 26, 2013 6:05:42 AM UTC+2, Aman Sharma wrote:
I am still not able to persist poll entity using Requestfactory in GWT. Please point out if there's anything wrong with following code.

view.setMsg("preparing");
PollRequest pr = requestFactory.pollRequest();
UserRequest ur = requestFactory.userRequest();
final UserProxy[] oldUser=new UserProxy[1];
ur.findUser(Cookies.getCookie("user")).fire(new Receiver<UserProxy>(){
@Override
public void onSuccess(UserProxy user){
oldUser[0]=user;
}
});

UserProxy editUser=ur.edit(oldUser[0]);

At that point, oldUser[0] still is 'null' (hint: requests are asynchronous)
 
PollProxy createdPoll = ur.create(PollProxy.class);
createdPoll.setQuestion(view.getQuestion());
createdPoll.setOptions(view.asEditor().getList());
createdPoll.setCloseTime(closeTime);
createdPoll.setUser(oldUser[0]);
editUser.setPolls(createdPoll);
ur.persist().using(editUser).fire(new Receiver<Void>(){
@Override
public void onSuccess(Void arg0){
view.setMsg("POll Created");
}
});

'pr' is never used; error in your code above?
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment