[jboss-user] [JBoss Seam] - Re: How To Cancel Update in Home Object
gzoller
do-not-reply at jboss.com
Fri Apr 20 13:26:00 EDT 2007
Carsten,
I think we're looking at the same problem from different angles. One desired behavior I'm looking for is the ability to cancel a data entry page w/o the changes popping up in the persistent state. I have one page in my app that does this just fine and one that (like yours) somehow persists and keeps the values I wanted to throw away upon cancel. I'll have to do a line-by-line comparison to figure out what the differences are.
The heart of my question is more about the ability to access a field's previous value prior to persisting it, for example in a Home object's update() method. Say for example in update() you'd like to take the difference between a field's old and newly set value and do something with the difference. How would you get the old value?
At the time update() is called the Entity's field has already been set in memory via setFoo(), so no help there. Aha, I thought---I can just hit the db with a query to temporarily pull back the previous value (the find() I show in my example code). But strangely the new value comes back from the query.
Here's what gets me: If I'm hitting the db from within the update() method the new value may exist in memory but hasn't (shouldn't) have been persisted until I call super.update(), right? So why am I getting the new value back? Hmm.
I'd love to know what others have done if they needed to compare old/new values of fields during setting or persisting. The only other thing I thought to try next is to save old values internally in the Entity (transiently of course) and hope that old value is still the last value set when update() is called.
Greg
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039365#4039365
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4039365
More information about the jboss-user
mailing list