Bear wrote:

> Craig,
>
> At 10:28 AM 1/24/2001 -0800, you wrote:
> >* Tell my users "deal with it -- this is a web application, not a
> >   web site, and the URL that you see is totally irrelevant."
>
> I'm perfectly comfortable with this regarding the displayed URL. But what
> about the refresh problem? Is there anyway to elegantly handle that?
>

Isn't that part of "deal with it"?  Why is the user pressing the Reload button
(or the Back button to return to a previously displayed page)?  Those are the
actions that you want to train them to avoid, and teach them to use only the
navigation controls you have provided within your pages.

NOTE:  Technology was recently added to Struts so that your application can
detect a duplicate post that was actually submitted.  It involves setting a
command token (whose current value is saved in the user's session) that must be
returned with the next submit.  If no such value (or a different value) is
returned, this can be detected by your Action and you can do the appropriate
thing (such as *not* add an item to the shopping cart twice).

This is used in the Struts example app on the registration page.  In the
EditRegistrationAction (that sets up the beans for registration.jsp) you will
see the call:

    saveToken(request);

down at the bottom.  Then, in SaveRegistrationAction (which processes the
submitted form) you see:

    if (!isTokenValid(request)) {
        ... deal with the error ...
    }
    resetToken(request);

Using this technique, the app will catch the case where the user presses Save on
the registration page, then presses the back arrow, then presses Save again.

No changes are needed to the JSP pages themselves -- the <html:form> tag
generates a hidden field automatically if needed.

>
> thanks
> bear

Craig


Reply via email to