RequestFactory: possible to load the whole object graph

202 views
Skip to first unread message

opn

unread,
Jan 11, 2011, 10:12:11 AM1/11/11
to Google Web Toolkit
Hello!

I've got entities which got child entities, which can have child
entities of themselves. I'm wondering if theres any trick to load more
than one level of depth?
If someone has done something like that i'd really like to know how
it's done.

Great work on RequestFactory in general btw.!

Thanks
opn

Thomas Broyer

unread,
Jan 11, 2011, 10:30:02 AM1/11/11
to google-we...@googlegroups.com

opn

unread,
Jan 11, 2011, 1:03:29 PM1/11/11
to Google Web Toolkit
Thx for the reply : ) i've already seen and used the .with! I think i
was not exact enough.
I've got self referencing entities that can go about 5 steps deep. And
i would like to fetch the root entity and all the children.
How would you do that?
Recursively going through all childs and building the dependencies
myself?

On 11 Jan., 16:30, Thomas Broyer <t.bro...@gmail.com> wrote:
> See:
>
>    -
>    http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g......)
>    -
>    http://code.google.com/intl/fr-FR/webtoolkit/doc/latest/DevGuideReque...
>
> <http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g......)>

Thomas Broyer

unread,
Jan 11, 2011, 1:55:29 PM1/11/11
to google-we...@googlegroups.com
You can use the "dot notation" for sub-sub-entities: .with("child.grandchild") Is this what you're looking for?

Y2i

unread,
Jan 11, 2011, 1:57:51 PM1/11/11
to Google Web Toolkit
Do you need all the children at once?
If not, you can use CellBrowser or CellTree (combined with a TreeModel
and data providers) to let the user interactively bring only the
children he/she needs .

opn

unread,
Jan 12, 2011, 9:18:13 AM1/12/11
to Google Web Toolkit
Thanks a lot!

I did not know that i can do this child.grandchild thing!
And CellBrowser / CellTree seems to be a better way than my first
thoughts!

Best regards
opn

Tiago

unread,
Oct 30, 2012, 8:13:24 AM10/30/12
to google-we...@googlegroups.com
Hello all,

I found this topic through Google. I have a similar problem.

I have a tree structure, with an arbitrary (dynamic) number of levels. Ex, an entity A which has a "children" relation which is a Set<A>.
Is there a way to load the entire tree with a single request in Request Factory?

I can't use the solution proposed in this discussion (with("child.grandchild...")) because I don't know in advance how many levels the tree will have. All I know is that it's a tree (no cycles) and that I may assume it's small enough to be downloaded in a HTTP request and stored locally on the client, in memory.

Thank you!

Alex opn

unread,
Oct 30, 2012, 11:11:57 AM10/30/12
to google-we...@googlegroups.com
Is there a way to load the entire tree with a single request in Request Factory?

No, there is not : / Although it would be nice and there was already an open issue for it. (http://code.google.com/p/google-web-toolkit/issues/detail?id=6697)
 
What you can do is use an async data provider if you show your tree structure through a celltree or a cellbrowser. But that introduces other problems. It's not that easy to refresh the data or traverse the tree to open all nodes or similar things. I'd really like to provide an example for an async data provider but don't have the time now.

HTH
opn

Tiago

unread,
Oct 30, 2012, 11:30:48 AM10/30/12
to google-we...@googlegroups.com
Thank you for your reply.

I'm actually displaying it in a Tree widget, not on a HasData. I guess I'll load it dynamically while the user clicks through the nodes. Or load it all at once in a series of recursive requests, don't know yet.

Richard

unread,
Oct 30, 2012, 4:58:44 PM10/30/12
to google-we...@googlegroups.com
Alternatively, just fetch all objects in a flat list, have each object hold their parent id, and build up the tree on the client end. A little bit of work but it'll be one fetch.

Alex opn

unread,
Oct 31, 2012, 10:04:58 AM10/31/12
to google-we...@googlegroups.com
Never thought about that : )

Btw: Here is the open issue about the possibility to load the whole object graph with RequestFactory: id 7082
Reply all
Reply to author
Forward
0 new messages