You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kamholz, Keith (corp-staff) USX" <kk...@moog.com> on 2002/07/03 15:00:17 UTC
Submit Actions
Hey everyone,
I have a question that may have a very simple answer. I have a small form
where the user enters an entry number. There are two submit buttons, one
for a 'Delete' and the other to 'Edit'. I want to send a different
parameter to the action depending on which button is clicked. It would
indicate whether a 'Delete' or an 'Edit' was requested. However, right now
my form tag just says <html:form action="/TWCMC.do?action=delete">. How can
I change this so that I can send the correct parameter that corresponds to
the button pressed? I'm sure someone knows how to this.
Thanks!
~ Keith
http://www.buffalo.edu/~kkamholz
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Submit Actions
Posted by Joe Germuska <Jo...@Germuska.com>.
At 9:00 AM -0400 2002/07/03, Kamholz, Keith (corp-staff) USX wrote:
>Hey everyone,
>I have a question that may have a very simple answer. I have a small form
>where the user enters an entry number. There are two submit buttons, one
>for a 'Delete' and the other to 'Edit'. I want to send a different
>parameter to the action depending on which button is clicked. It would
>indicate whether a 'Delete' or an 'Edit' was requested. However, right now
>my form tag just says <html:form action="/TWCMC.do?action=delete">. How can
>I change this so that I can send the correct parameter that corresponds to
>the button pressed? I'm sure someone knows how to this.
>Thanks!
If your submit buttons are regular HTML buttons (as opposed to
images) then the "value" of the button is sent as a request parameter
matching the name/property of the button.
something like this:
<html:form action="/TWCMC.do">
...
<html:submit property="action" value="delete" />
<html:submit property="action" value="edit" />
</html:form>
There was some recent discussion on the list about what to do if the
value of your button is localized, which makes it harder to test the
value of the parameter... I can't remember what the conclusion was,
but I imagine you could use the message resources in your action to
get the localized version of the string to compare to the parameter.
If you're using images instead of submit buttons, you might want to
check out Ted Husted's tip on ImageButtonBeans
<http://husted.com/struts/tips/index.htm>
I think you can manage this without JavaScript though.
Joe
--
--
* Joe Germuska { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get
glazed, they go white, their hands tremble.... As I watch them I
often feel that a dope peddler is a gentleman compared with the man
who sells records."
--Sam Goody, 1956
tune in posse radio: <http://www.live365.com/stations/289268>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>