Struts and DynaValidatorForm

A

Anders Steinlein

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
 
W

Wolfram Rittmeyer

Anders said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top