469,958 Members | 1,986 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,958 developers. It's quick & easy.

Preventing second click

Hi,

I have a Java GUI application where I perform a lot of long DB operations
[e.g. massive SQL Insert's],
which takes 5-60 secs to perform.
Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as soon
as it's done, re-enable it again.

I tried to do it in Javascript, just simple: <input... name=Save...
onclick="enabled=true;">
and as soon as screen refreshes, it re-enables the button automatically.
That works in some cases, however when I need to do some other Javascript
operation
(e.g. validate() the fields on the screen), disabling the button
automatically stops both Javascript
and association form action in Java which is totally unacceptable.

Is there any other simple solution to such problems in Java or Javascript ?

Thank you in advance,
Oleg.
P.S.: It probably doesn't matter much, but that is a Cocoon2.0/XSLT app with
Actions in Java,
using JDK1.4.2 and IE6.
Oct 22 '06 #1
10 3559
Oleg Konovalov wrote:
I have a Java GUI application where I perform a lot of long DB operations
[e.g. massive SQL Insert's],
which takes 5-60 secs to perform.
Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as soon
as it's done, re-enable it again.

I tried to do it in Javascript, just simple: <input... name=Save...
onclick="enabled=true;">
and as soon as screen refreshes, it re-enables the button automatically.
That works in some cases, however when I need to do some other Javascript
operation
(e.g. validate() the fields on the screen), disabling the button
automatically stops both Javascript
and association form action in Java which is totally unacceptable.

Is there any other simple solution to such problems in Java or Javascript ?
P.S.: It probably doesn't matter much, but that is a Cocoon2.0/XSLT app with
Actions in Java,
using JDK1.4.2 and IE6.
Sounds as if you need token pattern.

Arne
Oct 22 '06 #2
Read and enjoy!

http://javaalmanac.com/egs/javax.ser...ormts.jsp.html
"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:M2B_g.22708$2g4.5720@dukeread09...
Oleg Konovalov wrote:
>I have a Java GUI application where I perform a lot of long DB operations
[e.g. massive SQL Insert's],
which takes 5-60 secs to perform.
Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as
soon as it's done, re-enable it again.

I tried to do it in Javascript, just simple: <input... name=Save...
onclick="enabled=true;">
and as soon as screen refreshes, it re-enables the button automatically.
That works in some cases, however when I need to do some other Javascript
operation
(e.g. validate() the fields on the screen), disabling the button
automatically stops both Javascript
and association form action in Java which is totally unacceptable.

Is there any other simple solution to such problems in Java or Javascript
?
>P.S.: It probably doesn't matter much, but that is a Cocoon2.0/XSLT app
with Actions in Java,
using JDK1.4.2 and IE6.

Sounds as if you need token pattern.

Arne

Oct 22 '06 #3
Lew
(followup set to comp.lang.java.programmer)

John wrote:
Read and enjoy!

http://javaalmanac.com/egs/javax.ser...ormts.jsp.html
This is essentially the token pattern that Arne recommended, with a timestamp
as a token.

What might be advantage to using a timestamp over a String or arbitrary object
as a token?

- Lew
Oct 22 '06 #4
On Sat, 21 Oct 2006 22:53:32 -0400, Arne Vajhøj <ar**@vajhoej.dk>
wrote:
>Oleg Konovalov wrote:
>I have a Java GUI application where I perform a lot of long DB operations
[e.g. massive SQL Insert's],
which takes 5-60 secs to perform.
Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as soon
as it's done, re-enable it again.

I tried to do it in Javascript, just simple: <input... name=Save...
onclick="enabled=true;">
and as soon as screen refreshes, it re-enables the button automatically.
That works in some cases, however when I need to do some other Javascript
operation
(e.g. validate() the fields on the screen), disabling the button
automatically stops both Javascript
and association form action in Java which is totally unacceptable.

Is there any other simple solution to such problems in Java or Javascript ?
>P.S.: It probably doesn't matter much, but that is a Cocoon2.0/XSLT app with
Actions in Java,
using JDK1.4.2 and IE6.

Sounds as if you need token pattern.

Arne
Or use a solution like ASP.Net that does that for you instead of
requiring a custom hack.
Oct 22 '06 #5
No, I can not use an ASP.NET, it is a Java (/Cocoon/XSLT) application.

Thank you,
Oleg.
"Grok" <gr**@pregmail.comwrote in message
news:5r********************************@4ax.com...
On Sat, 21 Oct 2006 22:53:32 -0400, Arne Vajhøj <ar**@vajhoej.dk>
wrote:
>>Oleg Konovalov wrote:
>>I have a Java GUI application where I perform a lot of long DB
operations
[e.g. massive SQL Insert's],
which takes 5-60 secs to perform.
Sometimes user double-clicks the button or just gets impatient and
clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as
soon
as it's done, re-enable it again.

I tried to do it in Javascript, just simple: <input... name=Save...
onclick="enabled=true;">
and as soon as screen refreshes, it re-enables the button automatically.
That works in some cases, however when I need to do some other
Javascript
operation
(e.g. validate() the fields on the screen), disabling the button
automatically stops both Javascript
and association form action in Java which is totally unacceptable.

Is there any other simple solution to such problems in Java or
Javascript ?
>>P.S.: It probably doesn't matter much, but that is a Cocoon2.0/XSLT app
with
Actions in Java,
using JDK1.4.2 and IE6.

Sounds as if you need token pattern.

Arne

Or use a solution like ASP.Net that does that for you instead of
requiring a custom hack.

Oct 23 '06 #6
On Mon, 23 Oct 2006 02:10:23 GMT, "Oleg Konovalov"
<ok******@verizon.netwrote:
>No, I can not use an ASP.NET, it is a Java (/Cocoon/XSLT) application.

Thank you,
Oleg.
I guess I miss understood, I thought you said something about
Javascript.
Oct 23 '06 #7
Oleg Konovalov wrote:
Hi,
Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as soon
as it's done, re-enable it again.
I surrounded the entire form with a <div>, then placed an onSubmit="hideForm();" clause in the <form>. The code within hideForm changes the visibility
of the <divto hidden. Basically the entire form disappears from the user's screen. I have a second <divwhich starts out hidden and is made visible
at the same time the other div is being hidden. This div contains "Please wait, processing".

So the user clicks on a button, the form goes away, they get a "please wait" message, and the only buttons left are "Refresh" and "Back" in the tool bar.
Oct 23 '06 #8
Lew
(f-u set to comp.lang.java.programmer and comp.lang.javascript)
Oleg Konovalov wrote:
>Hi,
>Sometimes user double-clicks the button or just gets impatient and
clicks again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as
soon as it's done, re-enable it again.
Wojtek Bok wrote:
I surrounded the entire form with a <div>, then placed an
onSubmit="hideForm();" clause in the <form>.
An advantage of the token approach is that it is entirely server-side; it does
not rely on Javascript.

It also completely guarantees idempotency of the action.

I wonder, is it possible to double-click so fast that even Javascript might
not have time to react before the second click?

- Lew
Oct 24 '06 #9
Wojtek,

And how/when does the form get restored to the original state ?
Any code sample ?

Thank you,
Oleg.
"Wojtek Bok" <wb@nospam.comwrote in message
news:a24%g.29962$P7.21237@edtnps90...
Oleg Konovalov wrote:
>Hi,
>Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as
soon as it's done, re-enable it again.

I surrounded the entire form with a <div>, then placed an
onSubmit="hideForm();" clause in the <form>. The code within hideForm
changes the visibility of the <divto hidden. Basically the entire form
disappears from the user's screen. I have a second <divwhich starts out
hidden and is made visible at the same time the other div is being hidden.
This div contains "Please wait, processing".

So the user clicks on a button, the form goes away, they get a "please
wait" message, and the only buttons left are "Refresh" and "Back" in the
tool bar.

Oct 27 '06 #10
Oleg Konovalov wrote:
"Wojtek Bok" <wb@nospam.comwrote in message
news:a24%g.29962$P7.21237@edtnps90...
>Oleg Konovalov wrote:
>>Hi,
Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate records.
So I am trying to disable the button as soon as it is clicked, and as
soon as it's done, re-enable it again.
I surrounded the entire form with a <div>, then placed an
onSubmit="hideForm();" clause in the <form>. The code within hideForm
changes the visibility of the <divto hidden. Basically the entire form
disappears from the user's screen. I have a second <divwhich starts out
hidden and is made visible at the same time the other div is being hidden.
This div contains "Please wait, processing".

So the user clicks on a button, the form goes away, they get a "please
wait" message, and the only buttons left are "Refresh" and "Back" in the
tool bar.
top post fixed ...
Wojtek,

And how/when does the form get restored to the original state ?
When the user clicks on the button, the form onSubmit gets triggered. This runs the javascript code to hode the form and display the "Please Wait"
message. The normal submit action then happens:
- the web browser gathers the form field values
- the browser contacts the server and sends the field values
- the browser then waits for a response from the server
- when the response arrives, the web browser redraws the screen

In other words the normal cycle of a button click takes place
Any code sample ?
http://www.google.ca/search?hl=en&q=...=Google+Search
Oct 30 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Matt | last post: by
15 posts views Thread by bvdb | last post: by
13 posts views Thread by Oleg Konovalov | last post: by
15 posts views Thread by Baron Samedi | last post: by
2 posts views Thread by chrisp | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.