You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by M�ris Orbid�ns <M....@datapro.lv> on 2001/11/20 16:05:34 UTC
which button pressed?
Hello all
I have several submit buttons like this:
<table border="0">
<tr>
<td><html:submit property="prev"><bean:message
key="button.prev"/></html:submit></td>
<td><html:submit property="next"><bean:message
key="button.next"/></html:submit></td>
<td><html:submit property="save"><bean:message
key="button.save"/></html:submit></td>
<td><html:submit property="delete"><bean:message
key="button.delete"/></html:submit></td>
<td><html:submit property="add"><bean:message
key="button.add"/></html:submit></td>
</tr>
</table>
The question is: How to determine which one has been pressed ?
Maris Orbidans
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: which button pressed?
Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Careful with this.... you're tying your View with your Controller by way of
the button text. If your button text changes, so will your Action code. A
better solution in the case where the button name is the same for all
buttons is to use a solution I proposed on struts-dev recently:
http://marc.theaimsgroup.com/?l=struts-dev&m=100577282829753&w=2
The code posted will work as-is - I just want to split it up some more.
Erik
----- Original Message -----
From: "emmanuel.boudrant" <b7...@yahoo.fr>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, November 20, 2001 10:20 AM
Subject: Re: which button pressed?
>
> Hi,
>
> I suggest you to use : <html:submit property="propertyname"
value="buttonname"/>
> ex:
> <html:submit property="myAction" value="add"/>
> <html:submit property="myAction" value="del"/>
> and in Action class, to determine witch button is pressed:
> String button = request.getParameter("myAction");
> if ( button.equals("add") ) { ... }
>
> But I don't know if <html:submit property="propertyname"
value="</bean:message ... />"/> work ?
> Màris Orbidàns <M....@datapro.lv> a écrit :
> Hello all
>
> I have several submit buttons like this:
>
>
>
>
> key="button.prev"/>
> key="button.next"/>
> key="button.save"/>
> key="button.delete"/>
> key="button.add"/>
>
>
>
> The question is: How to determine which one has been pressed ?
>
>
> Maris Orbidans
>
>
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
>
>
>
> ---------------------------------
> Yahoo! Courrier -- Une adresse @yahoo.fr gratuite et en français !
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: which button pressed?
Posted by "emmanuel.boudrant" <b7...@yahoo.fr>.
Hi,
I suggest you to use : <html:submit property="propertyname" value="buttonname"/>
ex:
<html:submit property="myAction" value="add"/>
<html:submit property="myAction" value="del"/>
and in Action class, to determine witch button is pressed:
String button = request.getParameter("myAction");
if ( button.equals("add") ) { ... }
But I don't know if <html:submit property="propertyname" value="</bean:message ... />"/> work ?
Màris Orbidàns <M....@datapro.lv> a écrit :
Hello all
I have several submit buttons like this:
key="button.prev"/>
key="button.next"/>
key="button.save"/>
key="button.delete"/>
key="button.add"/>
The question is: How to determine which one has been pressed ?
Maris Orbidans
--
To unsubscribe, e-mail:
For additional commands, e-mail:
---------------------------------
Yahoo! Courrier -- Une adresse @yahoo.fr gratuite et en français !