How to block an online form?

We have a web application based on the form that passes. Unfortunately, when people look at it, it is edited. Thus, two people can edit it at the same time and overwrite their changes. How would you lock a form (and any several parts of the same form, because it is divided into several pages), so only one person can edit it at a time?

We want them to be able to edit the form for half an hour with one shot (they can save and continue to add more time).


I have one solution, but I wanted to see what other people think.

In my solution, when the user first looks at the form (or any parts of the form, because there are several parts that all need to be blocked), none of the fields can be changed until they hit the edit button. As soon as they press the edit button, a flag is entered with the user ID and start time. Then they are redirected to the same view that is editable. A javascript timer will be set at the bottom of the page to tell them how much time they have left. When they are finished, they click the "Save and Exit" button to save the changes, unlock the form for other users and return to the unprocessed form. To avoid using the back button to return to the editable form, I think an intermediate page containing javascript redirection will be used. Therefore, if they click the back button, they will simply be redirected back to the current page.

If they want to edit one of the subforms (there are buttons that redirect them to subforms from the main form), they can simply click one of these buttons in edit mode and it will save a large form, update the time to give them another half hour and redirect them to the editable subformat.

When a user tries to view a form that is currently being edited by another user, the edit button will not be available and the current user's information will be displayed along with the time when it should be open, but this time can be changed by the user when saving and editing the subform.


Does this sound like a viable solution? If you had to do the same, please let me know what is your solution to the problem?

+6
java-ee
source share
2 answers

There are several ways to deal with this situation. One of them blocks the form and allows you to edit only one edit at a time. Another is collision detection while saving and warning the user.

Blocking is most useful for highly competitive resources. If a lot of collisions are expected, it is better to click the "Change" button. This should mark the record as locked in your data store and allow only one user to edit it. The entry must be unlocked when the user saves the entry or when the user cancels. In a disconnected situation, for example, on a web page, there should also be an automatic unlock after a certain period of time.

Collision detection is performed by writing the version number or the last edited datetime and passing this to the client when viewing the page. The client then passes this back to the server when it clicks “Save,” and it is checked for the value in the database. If the value has changed, someone else has edited the entry, and the user may be warned about this. This system works much better for small changes, and when the resource is unlikely to be edited elsewhere (this usually happens when there are many small records compared to the number of active users).

I found that collision detection works better and is less frustrating for the user in web applications. Provided that the input text is small enough. This is due to the fact that blocking resources can hold them much longer than required, which is very frustrating

+5
source share

This is a viable solution, a bit difficult for visible management costs, but perhaps the most appropriate solution depending on the expected workflow.

Other approaches include:

but. Allow someone to edit and submit the form, but if someone else has submitted changes between the time that has passed since the form was opened, answer "conflict error." To improve this, if necessary, show two different sets of changes and let the user choose which ones to apply or try to merge the changes.

b. Create a form as an instant effects editor without a save button. Keep all open views in a form updated using XMLHttpConnection on the server so that when a user changes a field, each user is more or less instantly updated on any other copy of the form.

+1
source share

All Articles