tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Endre StĂžlsvik <En...@Stolsvik.com>
Subject Re: How to disable Backspace Button in the Keyboard
Date Fri, 01 Jun 2001 08:51:01 GMT
On Thu, 31 May 2001, Mike Haberman wrote:

| >
| > Whenever the user presses backspace key in the keyboard the browser goes to
| > the previous page, which crashes our site when the user tries to save its
| > contents once again or he loses data which have been typed.
| >
| > I think its remedy is to disable backspace button by JavaScript, but how
| > should I do it ?
| > If anybody know this code snippet please let me to know
|
| The remedy is to fix your site.  Even if you could capture the key stroke
| events,  ignoring the backspace is not the solution.  This advice falls in
| the same category as NEVER rely on javascript for something that is
| critical to your site.

A cool solution for this that actually works is that you use a Controller
and a Renderer servlet, the Controller taking all the parameters, and then
response.sendRedirect the user to the Renderer, storing whatever state is
neccessary in the user's session.

The nice thing is that you "skip" the Controller in the browser's history,
and (at least on Netscape), the history actually realizes that multiple
loadings of the same page is just "one event", and you end up with only
one history entry for your whole application. If you press back after
clicking 589 times in your application, you immediately exits back out of
your application to the page you were before those 589 clicks.

But of course, you have to put the "state" in the session too. A state
variable as in a state-machine (state diagram, whatever, you know the
circles with arrows pointing back and forth, each circle having a letter
or digit in it. ;), telling the system where you are, so that the user
can't f... up the routes in your application.

These two approaches together is an excellent solution, I feel. Some will
argue that the sendRedirect is more network traffic and what not, but in
reality you solve two pretty annoying issues by it, and that's worth it.

-- 
Mvh,
Endre



Mime
View raw message