struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad Rhoads" <brho...@zethcon.com>
Subject RE: Multiple submits
Date Tue, 30 Jul 2002 13:45:53 GMT



</SCRIPT><SCRIPT language="javascript" type="text/javascript">
<!--
//This include file contains some JavaScript functions to prevent users
//from submitting a form twice.  It sets a flag (FormSubmitted) to false
//when the page first loads.  Then, when the form is submitted, this flag
//is checked.  If it is true, it tells the user that they have already
//submitted the form and prevents the second submission.  If it is false
//it toggles the flag true (which prevents the next submission) and
//submits the form.  The flag can be reset if subsequent submissions are
//required.  One example would be if the user changes information on the
//form and then re-submits.  In this case, the ResetFormSubmitted function
//should be called in the onChange event of any form item that can be
//changed.

//Initialize the FormSubmitted variable
var FormSubmitted = false;

function DoubleSubmitCheck() //Call this function in the form's onSubmit
attribute
{
	//Check if the form has previously been submitted
	if(FormSubmitted) //It was
	{
		//Alert the user and cancel the submission
		alert("You have already submitted this form.  Please wait for it to be "
			+ "processed...\n\nNOTE:  If you pressed your browser's 'Stop' button"
			+ " after submitting this form, you'll have to press the 'Reload' or "
			+ "'Refresh' button before you can re-submit.")
		return false;
	}
	else //It was not (this is the first time it was submitted
	{
		//Set the FormSubmitted flag to true and return true to process the form
		FormSubmitted = true;
		return true;
	}
}

function ResetFormSubmitted()
{
	//Call this function if you wish to allow another submit, like if
	//data is changed
	FormSubmitted = false;
}
//-->
</SCRIPT>



<form method="POST" name="custinfo" action="xxx" onSubmit="return
DoubleSubmitCheck();">

-----Original Message-----
From: Rahul Kumar Saxena [mailto:rahul.saxena@wipro.com]
Sent: Tuesday, July 30, 2002 5:36 AM
To: struts-user@jakarta.apache.org
Subject: Multiple submits



Hi All,

I am facing a problem related to multiple sumbits.

We are developing a wizard kind of application with frames. For this we
use business object(BO), which are nothing but a replica of forms, used
in JSPs. We store this BO in session and keep on updating it with the
values present in various forms. At the end, we pass this BO to EJB
layer to process the DB operations after which we display success or
failure page depending on the success of DB operation. To do final
submit we display OK and Cancel button in all the JSPs along with Next
button. After successful DB operation we remove BO from session (to make
session light).This is where our problem starts.

If user clicks final OK and first thread completes the DB operation;
just before the success page loading user clicks Next button. Then
second thread tries to look into BO which was stored in session, for
some values. Since first thread has already removed the BO from session,
second thread throws NullPointerException. Not only this if user clicks
OK button, more than once then we land up either with same record
entered in DB more than once or again NullPointerException.

I went through various threads and almost every where people talk about
using Tokens. If I use tokens then what shall I do if token is invalid?
I can't show him a page saying that your first request is under process,
'coz at the end I have to forward the request to success page.

TIA,
*********************************************************
RAHUL K. SAXENA
Sr. Systems Engineer,
Wipro Technologies,
Ground Floor, Tower II,
72, Electronic City,
Hosur Main Road,
Bangalore-561 229, India.
Ph: 91-80-8520408/416(x-2026)
*********************************************************



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message