Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback or Cancel behaviour #51

Open
taras opened this issue Aug 4, 2013 · 5 comments
Open

Rollback or Cancel behaviour #51

taras opened this issue Aug 4, 2013 · 5 comments

Comments

@taras
Copy link
Contributor

taras commented Aug 4, 2013

I have a cancel button in an edit view and I'd like to cancel all changes when that button is pressed.

Do I manipulate the session or the model to rollback the changes?

@c0urg3tt3
Copy link

you can have a look at the shadow of session as described in comment of this issue #22

@taras
Copy link
Contributor Author

taras commented Aug 4, 2013

@c0urg3tt3 works, is this how it should be done going forward?

@ghempton
Copy link
Contributor

ghempton commented Aug 5, 2013

I am probably going to add a rollback method to session at some point. But the more idiomatic way to do this is to use a child session (e.g. session.newSession()). To cancel all the changes that have taken place in a child session you can just opt to never call flush.

@jasonkriss
Copy link
Contributor

We use childSession when we have a dedicated edit view but as far as I can tell there are some situations where using a childSession isn't possible. For example, we have a customer profile page that allows a user to edit the name and other attributes in place without having to first click an edit button. If the user escapes from the input while editing, we need to rollback. I'm not sure how this would be done using a childSession.

@ghempton
Copy link
Contributor

ghempton commented Aug 6, 2013

@jasonkriss this is partially why the current behavior for childSessions is to flush into the parent session immediately. In your profile case you could create a child session upon edit and simply flush when they click save.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants