What's is the best way to prevent multiple submission when I'm using XPages?
For "classic web" solution is below. How to Block Multiple Submissions of the Same Document from the Web http://www-304.ibm.com/support/docview.wss?uid=swg21089865
Using jQuery, the solution is below. http://www.norio.be/blog/2008/09/using-jquery-prevent-multiple-form-submissions
But I don't know the way in Xapges. How to prevent it in XPages or Dojo?
It is best not to apply such client-side techniques, because combined with an unreliable internet connection the user may find that the submission fails but be unable to retry.
A much more robust solution is to deduplicate on the server side, which can be done in a variety of ways; these are some that come to mind:
- Define the semantics of your form contents so that it doesn't matter if you receive two requests (e.g. if it is updating a record, then a second update just changes nothing).
- If you have seen the exact same submission before (compare all the relevant fields), ignore it.
- Generate a serial number when you send the form to the client. Don't accept submissions that have a serial number you've seen before — or do something useful; for example, if it is a blog posting or comment form, then a second submission should be treated as an edit to the post created by the first submission.