Slightly inefficient I suppose, as the changes made to the Entity will
still get sent to the server even when calling remove(). If you don't
want to send the changes when calling remove, simply do not fire() the
context you are editing in (effectively throwing it away), and create
a second context to call remove() on.
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/85SdohRBg6sJ.
> 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.
>
If you don't
want to send the changes when calling remove, simply do not fire() the
context you are editing in (effectively throwing it away), and create
a second context to call remove() on.
Oops, I was mistaken, you cannot have two mutable versions of the same
proxy at once, so you cannot simply not fire() the context to discard
it as I said. !
Seems like there should be a way to discard a context and any
accumulated changes in that case.. I don't see a way to do this in the
docs..
It sounds like your actually persist()'ing the object and then
remove()'ing it in a subsequent request. Not a big deal, but it is
possible to do it in just one request. Its a matter of keeping around
the RequestContext you pass to your editor driver, and deciding which
service method to invoke on it later. Say its called 'editContext' and
you start your editing like:
editor.edit(proxy, editContext);
Later you can either persist:
editor.flush(); // flush() returns the RequestContext passed into
edit(), for convenience, but we are keeping it around anyway.
editContext.persist().using(proxy)
editContext.fire();
Or remove:
// No need to call flush(), we don't care about any changes.
editContext.remove().using(proxy)
editContext.fire();
I think in a few of the docs/examples, the persist() method is queued
at the same time as starting the editing, but it can be delayed until
later, when you know you are actually going to persist it. Again, its
just a matter of keeping around the 'editContext' and deciding which
method to call on it once you know.
PS. Your persist()/remove() calls might look like 'persist(proxy)',
instead of 'persist().using(proxy)'