RequestFactory and Collections

26 views
Skip to first unread message

Tobias

unread,
Nov 3, 2010, 12:09:03 PM11/3/10
to Google Web Toolkit
Hi,

I am working on an example application to learn about RequestFactory
and the new Editor framework. The idea is to edit a Recipe, which has
multiple ingredients. The ingredients are displayed in CellTable. This
still involves a couple of problems (e.g.,
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/1725bc619a4459ab#
), but I got it working to the point, where the Request seems to be
correcty set up and contains the edited RecipeProxy as well as
multiple IngredientProxy instances.

When I edit a direct property of the Recipe, eg the name (String), on
the server Recipe.persist() is called and I can save the updated
object easily (I am using Objectify for this).

However, when I am editing a String property "text" on one of the
Ingredients, Ingredient.persist is NOT called for the edited
instance.

I looked at the raw JSON of the request made, and it seems to include
the updated Ingredient instance. Unfortunately, the DynatableRf and
the Expenses examples don't deal with n-ary relationships on the
entities. How is this done? Are there any more naming conventions for
handling collections?

My proxy interfaces currently look like this:

@ProxyFor(Ingredient.class)
public interface IngredientProxy extends EntityProxy {

String getId();

String getText();

void setText(String text);

@Override
EntityProxyId<IngredientProxy> stableId();

}

@ProxyFor(Recipe.class)
public interface RecipeProxy extends EntityProxy {

long getId();

String getName();

void setName(String name);

@Override
EntityProxyId<RecipeProxy> stableId();

List<IngredientProxy> getIngredients();

void setIngredients(List<IngredientProxy> ingredients);
}



Regards,
Tobias

David Chandler

unread,
Nov 3, 2010, 2:54:19 PM11/3/10
to google-we...@googlegroups.com
Tobias,

RequestFactory doesn't do cascading updates or deletes. You'll have to
make a separate call from the client to do this (or possibly you could
implement in the parent entity's persist() method). By the way,
persist() is just an example method name. As far as RequestFactory is
concerned, it's just another service method that you create.

HTH,
/dmc

> --
> 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-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

--
David Chandler
Developer Programs Engineer, Google Web Toolkit
http://googlewebtoolkit.blogspot.com/

Tobias

unread,
Nov 3, 2010, 3:05:26 PM11/3/10
to Google Web Toolkit
David,

Thanks for your reply. So the RequestFactory calls persist on my
server-entity, because I call "persist" on the Request-object. In this
case though, I don't understand why RequestFactory transmits the whole
object-graph and what happens to it on the server?
Can you elaborate on how I could implement the children's update in
the parent entity's persist method?

Thanks,
Tobias

On Nov 3, 7:54 pm, David Chandler <drfibona...@google.com> wrote:
> Tobias,
>
> RequestFactory doesn't do cascading updates or deletes. You'll have to
> make a separate call from the client to do this (or possibly you could
> implement in the parent entity's persist() method). By the way,
> persist() is just an example method name. As far as RequestFactory is
> concerned, it's just another service method that you create.
>
> HTH,
> /dmc
>
>
>
>
>
>
>
>
>
> On Wed, Nov 3, 2010 at 12:09 PM, Tobias <thaberm...@gmail.com> wrote:
> > Hi,
>
> > I am working on an example application to learn about RequestFactory
> > and the new Editor framework. The idea is to edit a Recipe, which has
> > multiple ingredients. The ingredients are displayed in CellTable. This
> > still involves a couple of problems (e.g.,
> >http://groups.google.com/group/google-web-toolkit/browse_thread/threa...
> > For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en.

Tobias

unread,
Nov 3, 2010, 3:26:49 PM11/3/10
to Google Web Toolkit
I now realized that actually setText() is called for the server
Ingredient-entity. But I'm not sure if that helps me, since the Recipe
instance does not know anything about the Ingredient-instance on which
that happens. But I guess that's more an Objectify-problem then. Maybe
I'll switch to JDO for now.

Thanks anyway,
Tobias
Reply all
Reply to author
Forward
0 new messages