Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

when i pressing search button mutilple times my code is brake  RSS feed

 
Bawan Kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i press onces then its ok ....when i pressing search button mutilple times my code is brake ...... how to solve ???
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this article paying particular attention to the P-R-G pattern.
 
Shailendra Gatade
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you mean the code works fine if you clicked only once ? If thats the case then a quick fix can be done by adding a bit of javascript to disable the submit button once its clicked.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While that can help, JavaScript can be disabled. It's also important to use proper patterns on the server to prevent this from happening.
 
Shailendra Gatade
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Partially agree abou the patterns on the server side. The problem here it seems is the user clicking the UI button multiple times.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Partially" agree? The server-side should always be bullet-proof regardless of what happens on the client. Anything else is just reckless.

It's like validation -- never assume something is taken care of on the client; always make the server-side code robust!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36463
461
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:"Partially" agree? The server-side should always be bullet-proof regardless of what happens on the client. Anything else is just reckless.

Absolutely! I don't see how post-redirect-get helps with this scenario though. That helps if the user presses refresh after the next page comes back. Wouldn't you need a token to detect a duplicate request from the query/submit page for the user who clicks it twice at their end?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not clear, to me at least, whether the OP is talking about double-clicking or clicking again after a POST is left hanging. PRG helps in the latter case. Both situations need to be able to be handled by the server without resorting to JavaScript tricks.

P.S. I do use the "JavaScript tricks" as well -- but only because it makes it nice for the user. The sever does not rely upon them.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!