Updating object through GWT RPC can easily be undone. We need to clone previous entity state in memory and apply it upon undo.
But when we use RequestFactory there is no concrete update operation. RequestFactory sends entity modifications to the server and updates repository entities itself. We cannot intercept update process.
How should I implement undo for updates made with RequestFactory?
You should look into modifying your server-side data structures and tables. Incorporate a temporal or bitemporal model there. Don't bother trying to hold "old" states of entities in memory, or intercept them. Keep the prior states of entities intact with time fields. Undo means locating a prior version by timestamp, and making it current. You can do this across multiple entity types simultaneously as well.
If you want to, you can periodically sweep your database and clean up old versions. The "append-only" style of temporal writes can yield performance benefits as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With