473,385 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 3693
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Matt | last post by:
I have an interactive web page that I need to prevent refreshes on. The problem is that I want to ALLOW resubmissions, but only via the submit button. My web page has two forms on it, one form for...
2
by: BenM | last post by:
Description: I would like to prevent a user from logging in with their user/password combination on a different computer or even a different browser window, if they are already logged in. I have...
7
by: Rex | last post by:
Hi all, I want to protect the data on my web page ; I want to make it viewing-only. I've already disabled right-click, but can I take it one step further, and disable certain pulldown menus...
15
by: bvdb | last post by:
Hello, my web-application uses two frames, one with a list of database records, one with a record detail view. From the detail view there is "mark" function that will mark the respective record in...
1
by: R Reyes | last post by:
Hi, For some reason, the website I made does not open pages in a new page whenever I right-click "Open in New Tab" or "Open in New Window". But, as soon as I navigate to any other website, the...
13
by: Oleg Konovalov | last post by:
Hi, I have a Java GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks...
15
by: Baron Samedi | last post by:
Every so often, I see someone wanting to prevent heir images being downloaded and the general consensus is "you can't". Now a friend has asked me to think some more about this, and I think that...
2
by: dwmartin18 | last post by:
I got it into my head the other day to develop my own little form validation library. More than anything I just wanted to try out of few things I’ve never done before like chainable methods -- think...
1
by: RLN | last post by:
RE: Access 2003 Current setup is: Front end .mdb (Interface, queries, macros, etc) /Back end .mdb (Database Tables) I'm trying to write some code that will prevent users from getting into the...
2
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.