struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From RogerV <roger.var...@googlemail.com>
Subject Forms with Multiple Submit buttons (Bug or Expected?)
Date Wed, 19 May 2010 09:41:08 GMT

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

-- 
View this message in context: http://old.nabble.com/Forms-with-Multiple-Submit-buttons-%28Bug-or-Expected-%29-tp28606047p28606047.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Mime
View raw message