Struts and DynaValidatorForm

Discussion in 'Java' started by Anders Steinlein, Aug 26, 2003.

  1. I have an HTML form that maps to a DynaValidatorForm I have specified in
    the struts-config.xml file. Everything works fine, but I have come across
    a potential problem I don't know how to solve:

    If the user quickly clicks the submit button multiple times, my Action
    and corresponding database calls are requested for each click! As
    impatient users are bound to multiple-click from time to time, what is
    the best way to solve this? Definately preferably with still being able
    to use DynaValidatorForm...

    Thanks!

    \Anders
    Anders Steinlein, Aug 26, 2003
    #1
    1. Advertising

  2. Anders Steinlein wrote:
    > I have an HTML form that maps to a DynaValidatorForm I have specified in
    > the struts-config.xml file. Everything works fine, but I have come across
    > a potential problem I don't know how to solve:
    >
    > If the user quickly clicks the submit button multiple times, my Action
    > and corresponding database calls are requested for each click! As
    > impatient users are bound to multiple-click from time to time, what is
    > the best way to solve this? Definately preferably with still being able
    > to use DynaValidatorForm...
    >
    > Thanks!
    >
    > \Anders


    You could generate a unique token which is generated before the jsp-page
    is to be called (in your action therefore). Then you place this token in
    a hidden form-field of your JSP and in the following Action you check
    whether this token has already been used. If not, mark it as used and
    perform you're DB-related code. If used, just ignore the DB-related
    tasks and simply prepare the next view.

    So you must have some way to deal with these tokens (could be a seperate
    class which stores these in an HashTable with the token as key and the
    status as a wrapped boolean - this of course should be using
    getters/setters which are implemented in a thread-safe way).

    Wolfram Rittmeyer
    http://www.jsptutorial.org
    Wolfram Rittmeyer, Aug 27, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Katie Wright
    Replies:
    8
    Views:
    4,238
    Andrea Desole
    Jan 7, 2005
  2. Ron
    Replies:
    2
    Views:
    1,929
  3. javaguy44
    Replies:
    0
    Views:
    834
    javaguy44
    Apr 26, 2004
  4. Merlijn
    Replies:
    0
    Views:
    3,446
    Merlijn
    Mar 24, 2006
  5. pit_IN
    Replies:
    0
    Views:
    687
    pit_IN
    Jul 30, 2006
Loading...

Share This Page