I have an entity with an one-to-many relationship, and a single view on the
app where such entities are created, populated and persisted (Using
requestfactory).

At first, I thought I should create the requestcontext and instantiate a new
proxy of the entity when the view is started, like this:
request = myRequestFactory.fooRequest();
foo = request.create(FooProxy.class);

Then, during the view execution the properties of the entity would be
populated (including the relationship)

And when the user press "save", I would call a method on the service to
persist the whole entity in a single step, that is: There will be only one
service method call

Is this the right way of working with requestfactory?

I had trouble with adding elements to the one-to-many relationship... My
code was like this:
BarProxy bar = request.create(BarProxy.class);
bar.setXxx(...);
foo.getItems().add(bar);

But getItems() returns null, so it failed.

Then I created another service method called addBar which takes a Foo and a
Bar, and add the Bar to foo.getItems(). So now my client code where I add
elements to the collection was like:
BarProxy bar = request.create(BarProxy.class);
bar.setXxx(...);
request.addBar(foo, bar);

And then when the user wants to save, I just call request.persist(foo);

However, as I'm now calling service methods with objects that aren't
completely filled, I got validation errors. So, I had to completely disable
entity validation using a servicelayer decorator. It seems to work now, but
I didn't like how I've done this whole process

Maybe I'm not using requestfactory as it should be used, and that caused my
issues. What would be the right way to work?

-- 
Magno Machado Paulo
http://blog.magnomachado.com.br
http://code.google.com/p/emballo/

-- 
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