File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts +Error handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts +Error handling " Watch "Struts +Error handling " New topic

Struts +Error handling

A knibbs
Ranch Hand

Joined: Aug 23, 2006
Posts: 158
I am working on a struts application where multiple people have the potential to touch the same files. Because of this I need to ensure that they don't overwrite each others work. My thought process is when a person clicks to edit a form keep a copy of the information as it was when the edit started. When the user tries to submit I will check to see if the data has changed before committing the change. The part that I am not 100% certain what to do is if the data has changed I am throwing a DataIssueException. When it goes to my action controller how would I go about warning the user that someone else has changed the data since they started ?
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I would think you would treat this basically the same as a validation error. Save the ActionError/Message and forward the user to the same place as the input attribute.

From a processing stand point, what do you plan to do when this occurs? Show the user a message saying "I know you just spent 10 minutes updating this data but somebody else changed one of the fields so I am going to throw away all your changes and force you to restart" ;-) Is your code smart enough to know which fields changed and to merge the changes?

- Brent
A knibbs
Ranch Hand

Joined: Aug 23, 2006
Posts: 158
The changes being made would most likely never take more than 2 minutes, but it's still something that I have to worry about. I don't think it would make sense to merge the changes, as some fields are dependant on others. The manner in which I decided to deal with it is to allow the user to decide if they wish to continue with the changes or if they wish to stop the changes and go reload the form. Perhaps not the best option, but it is already extremely unlikely that this situation will occur.
I agree. Here's the link:
subject: Struts +Error handling
It's not a secret anymore!