On 25 oct, 20:50, Rafi <[email protected]> wrote:
> On 25 Paź, 20:29, Thomas Broyer <[email protected]> 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<B> or Set<B>).
>
> 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 [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