Re: Idea of RequestFactory
You could add the with("address") to the findAll call: requestFactory.personRequest().findAll().with("address").fire(...); -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Idea of RequestFactory
> AFAICT, actually, when doing your second request > (find(personId).with("address")), the previous entity proxy will be > updated; i.e. for each proxy there's a "canonical", immutable instance > that's being updated in place when a response comes back from the > server, and there are "editable" instances bound to a RequestContext > after a call to the RequestContext's edit() method (the editable/ > mutable instance is cloned from the canonical one at the time edit() > is called). > This is at least what I understand from reading the source of > AbstractRequestFactory, AbstractRequestContext and AbstractRequest. Well, it seems that there is a bug probably or I am doing something wrong, because my previous instance does not get updated. Still calling getAddress() returns 'undefined', however in newly fetched Person entity calling getAddress behaves as expected - address is returned. Best regards! Rafal -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Idea of RequestFactory
On 25 oct, 20:50, Rafi wrote: > On 25 Paź, 20:29, Thomas Broyer wrote: > > > """ > > When querying the server, RequestFactory does not automatically > > populate relations in the object graph. To do this, use the with() > > method on a request and specify the related property name as a String: > > > Request findReq = > > requestFactory.personRequest().find(personId).with("address"); > > """ > > Source:http://code.google.com/webtoolkit/doc/trunk/DevGuideRequestFactory.ht... > > > In your case, you'd have to do a with("b"), as your property is named > > getB(). it works the same whichever the type of the property (B, > > List or Set). > > OK, but lets assume this: > At the beginning there are lots of Person entities. I don't need their > addresses until user choses one particular Person entity. So at the > beginning I do: > > requestFactory.personRequest().findAll(); > > Then, user chooses one particular Person entity and this is a moment > when I need address entity. I can do: > > requestFactory.personRequest().find(personId),with("address"); > > But this will cause: > 1. Getting of Person entity which I already hold. > 2. Creating new instance of Person entity and I have to look after > proper instance, as the old one does not contain address. > > Is there any other way to solve this without above side effects? AFAICT, actually, when doing your second request (find(personId).with("address")), the previous entity proxy will be updated; i.e. for each proxy there's a "canonical", immutable instance that's being updated in place when a response comes back from the server, and there are "editable" instances bound to a RequestContext after a call to the RequestContext's edit() method (the editable/ mutable instance is cloned from the canonical one at the time edit() is called). This is at least what I understand from reading the source of AbstractRequestFactory, AbstractRequestContext and AbstractRequest. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Idea of RequestFactory
On 25 Paź, 20:29, Thomas Broyer wrote: > """ > When querying the server, RequestFactory does not automatically > populate relations in the object graph. To do this, use the with() > method on a request and specify the related property name as a String: > > Request findReq = > requestFactory.personRequest().find(personId).with("address"); > """ > Source:http://code.google.com/webtoolkit/doc/trunk/DevGuideRequestFactory.ht... > > In your case, you'd have to do a with("b"), as your property is named > getB(). it works the same whichever the type of the property (B, > List or Set). OK, but lets assume this: At the beginning there are lots of Person entities. I don't need their addresses until user choses one particular Person entity. So at the beginning I do: requestFactory.personRequest().findAll(); Then, user chooses one particular Person entity and this is a moment when I need address entity. I can do: requestFactory.personRequest().find(personId),with("address"); But this will cause: 1. Getting of Person entity which I already hold. 2. Creating new instance of Person entity and I have to look after proper instance, as the old one does not contain address. Is there any other way to solve this without above side effects? Best regards! Rafal -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Idea of RequestFactory
On 25 oct, 13:14, Rafi wrote: > Hi! > > I am playing around with new RequestFactory feature available in 2.1, > and actually I think that I don't get the idea. > > At first i thought, that RequestFactory will bring me something like > local domain model. > Lets assume that entity A and proxy for it are present. Lets assume > that this entity A has method getB() that returns entity B (proxy for > this entity is also present). Now when I request for object A it is > returned, but calling getB() causes "undefined" error. I would expect > that this entity will be get from the server. Or I could load this > entity B explicitly, but when I do this entity A still knows nothing > about B. I can load again A with B, but this will give me whole new > instance of A. > > I thought that it will be automatic or semiautomatic consistent local > domain model. > > I cannot load all As with all Bs, because in my GUI user only selects > one A, and for this A I will need its Bs. Getting all As and all Bs at > start will cause loading lots of data. I need to build a model that is > updated with new parts from server depending on what actions user > takes. > > What am I missing? """ When querying the server, RequestFactory does not automatically populate relations in the object graph. To do this, use the with() method on a request and specify the related property name as a String: Request findReq = requestFactory.personRequest().find(personId).with("address"); """ Source: http://code.google.com/webtoolkit/doc/trunk/DevGuideRequestFactory.html#relationships In your case, you'd have to do a with("b"), as your property is named getB(). it works the same whichever the type of the property (B, List or Set). -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Idea of RequestFactory
Hi! I am playing around with new RequestFactory feature available in 2.1, and actually I think that I don't get the idea. At first i thought, that RequestFactory will bring me something like local domain model. Lets assume that entity A and proxy for it are present. Lets assume that this entity A has method getB() that returns entity B (proxy for this entity is also present). Now when I request for object A it is returned, but calling getB() causes "undefined" error. I would expect that this entity will be get from the server. Or I could load this entity B explicitly, but when I do this entity A still knows nothing about B. I can load again A with B, but this will give me whole new instance of A. I thought that it will be automatic or semiautomatic consistent local domain model. I cannot load all As with all Bs, because in my GUI user only selects one A, and for this A I will need its Bs. Getting all As and all Bs at start will cause loading lots of data. I need to build a model that is updated with new parts from server depending on what actions user takes. What am I missing? Best regards! Rafal -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.