Is there a way to lock a form if the form is in use? The intention is to avoid two users submitting the same form.
- Pessimistic locking, and
- Optimistic locking
This pretty much works, but you also need a good routine for unlocking the order, since some people will invariably fail to complete the workflow and leave a record locked.
For an optimistic lock, you need a version flag on the record. When someone retrieves the record, you include the version number. Before saving the record, you check the version in the database. If it doesn't match, then someone else has beaten your user to the punch, and you branch to a page explaining the problem.
Scott Ambler's papers provide some good background about this
Struts in Action
For keeping someone from submitting the same form twice, Struts has a built-in token feature, but that's a different question =:0)