Struts DispatchAction
843838Sep 5 2005 — edited Sep 5 2005Hey, I need to create a form with multiple submit buttons, but I want to deal with them all in a single action class.I think if I use a dispatchAction, and specify 'method' as the parameter attribute for the action in the struts-config, and I use the following code:
<html:submit property="method" value="Start" />
<html:submit property="method" value="Stop" />
<html:submit property="method" value="Reset" />
it will call the Start(), Stop(), and Reset() methods repectively. Problem is, some of my submit buttons need values with spaces in them, like "Add Data"...I'm wandering how I can get it to call an appropriate method in this case. I thought about using a hidden field instead for the action parameter - which I will embed within each submit field...ie.:
<html:submit value="Add Data">
<html:hidden property="method" value="addData" />
</html:submit>
<html:submit value="Start">
<html:hidden property="method" value="start" />
</html:submit>
Would this submit the appropriate value for the hidden field depending on the submit button pressed? I'd rather do this than use javascript to set a single hidden field....