Let's assume following scenario. There is a collection of Animals
in the Zoo
. User may add and/or remove animals to the Zoo
and when he is ready, he can hit save to send request.
We are handling adding new animal using:
AnimalProxy animal = saveRequest.create(AnimalProxy.class);
animal.setZoo(zoo);
zoo.getAnimals(animal);
...
But what if user changes his mind and decide to remove animal he just created/added from zoo before saving?
Because this animal is already managed by saveRequest
we would need to somehow unbind it from saveRequest
(so that this animal won't be send to server). But RequestContext
interface offers only methods for adding proxies to it (edit()
and create()
), but there is no single method of removing proxies. Any way to do it?
The solution to my question was just accepting the fact that canceled AnimalProxy
were sent to server but making sure that it will not be persisted on server side. There is probably no way to remove proxy from RequestContext
at the moment.