Problem with "double commit"

X-Application Version: 3.1.2
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 4.0.2
JDK Version : 1.3.1_01

I have a small problem with X-Application’s create/commit logic. When creating a new instance (for example, using the X-Application Property example application), if the user clicks fast and repeatedly on “Commit”, he gets an error page like this:

code:

Minor Environment Exception
A minor environment problem occurred in the application program. Normally this problem is solved after a retry of the operation.
Error message: 206: Trying to make changes to a new document while docid=/Property[@ino:id=‘27’] is currently referenced.
Help message: The request indicates that values have to be set for a new document, but the server maintaince an existing document.
Exception class: com.softwareag.xtools.xapplication.jsp.InvalidActionException

This is really a user error (a single click on commit works fine). But what I would like to do is to disable the Commit “button” as soon as it is clicked. Is this reasonable/possible?

[This message was edited by Harald Wolf on 20 Mar 2002 at 12:25.]

Puh, thats a difficult problem.

From the servlet container’s point of view
your “double” click just look like two normal
requests. The first request is processed (i.e.
the document is commited) and the follow up page
is sent to the client. However, this page is
discarded since the second request is processed
… and results in an error since the document
has already been commited.
As far as I know, static html pages have the
same behavior: if you click on a second
(different) link, the second request overrides
the first.

This problem is basically the same with every
link - not just commit. But the behavior will
be slightly different.

What could we change on the server side to
improve the situation? Discard requests
if the previous request is still processed?
(Currently, we just queue up requests.)
This could be possible, the respective code is
in jsp.ServletSessionContext.findSessionContext.
But I don’t what to send to the client (i.e.
your browser) in this situation. Something to
make him forget the response and use the response
of the previous request instead. I don’ know.

Maybe something else. Do you know JavaScript?
I don’t, but it could be possible to intercept
the “click” by a JavaScript script, disable the
link first and then send the request.
Yes, I think that’s the path you should try.
Is there anybody who knows JavaScipt?


Michael


PS: Just changing the error message is possible as
well, but there are quite a few messages you had
to change since there are many “double” clicks
to produce a problem.

Software AG Germany, Darmstadt

Thanks for the idea Michael. This small javascript seems to work. It submits the specified form and then disables the form to stop a re-submit. The sequence of these two events is important. If you disable the form before you submit it, no parameter values get transmitted with the submit event.

code:

…and later…

<bdm:action type=“commit” form=“form1”>
<a href=“javascript:submitAndDisable(‘form1’)”


</bdm:action>


HTH