struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis Cabasson <>
Subject Re: Forms with Multiple Submit buttons (Bug or Expected?)
Date Wed, 19 May 2010 12:21:30 GMT
Why not doing that on the server side, using the s:token approach? That 
would prevent double submit on the server side.
On the client side, I would say that your disabling the button before 
the form is submitted (the onsubmit technically happens before the 
submit, so that you can uypdate some value before the submit of the form 
actually happens) prevents the value of this button to be sent to the 
server (which makes sense, since it's disabled). I would recommend not 
disabling the button (as the formsubmitted var will be enough to prevent 
a re-submission). If you really want to disable your button, consider a 
timer that would do so 200ms after, leaving time for the form to be 
submitted *with* the value of this button.


Le 2010-05-19 05:41, RogerV a écrit :
> For a long while I've been building forms along the lines of
> <s:form>
> ......
> <s:submit id="submit" type="button" label="Continue" action="processForm"/>
> <s:submit id="cancel" type="button" label="Cancel"
> action="goSomewhereElseWithoutSubmittingTheForm/>
> which has worked well. Until today. Today I needed to prevent a double
> submit on a form so I chose the quick way by creating a javascript onsubmit
> handler to cancel the button after the first click and referenced it in the
> s:form onsubmit handler
> <script type="text/javascript">
> 	var formsubmitted=false;
> 	function preventDoubleSubmit() {
> 		if (formsubmitted) {
> 			return false;
> 	}
> 		var submitButton = document.getElementById('submit');
> 		submitButton.disabled=true;
> 		formsubmitted=true;
>          return true;
> 	}
> </script>
> On clicking the submit button, the javascript disabled the button but the
> performAction was never called and the form was redisplayed. So I tried
> again, moving the javascript to the submit buttons onclick attribute. Same
> thing. Looking at the POST through Firebug I see that without any javascript
> handlers it looks like;
> <form data>&action%3performAction=Submit
> and with the javascript handlers
> <form data>  i.e the Struts action information is not being attached.
> Is this expected or a bug? Am I handling multiple submit buttons in the
> wrong way?
> Regards

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message