struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Trzupek <btrzupe...@mac.com>
Subject Re: checking whether a button has been pressed
Date Fri, 27 Jul 2007 13:13:15 GMT
Session,

I would recommend using the method attribute of the submit tag. This  
allows you to specify a method that will be executed when the form is  
submitted with that given input button. Example is:

<s:submit value="toDelete"  method="delete"/>
<s:submit value="toSave"  method="save"/>
<s:submit value="toOther"  method="other"/>

Then your your Action Class implement methods like:

     public String save() throws Exception {
         .... your logic here .....
         return SUCCESS;
     }

     public String delete() throws Exception {
         .... your logic here .....
         return SUCCESS;
     }

     public String other() throws Exception {
         .... your logic here .....
         return SUCCESS;
     }

This pattern has proven wonderfully useful in our development.

Brian Trzupek

On Jul 26, 2007, at 2:31 PM, Session A Mwamufiya wrote:

> Hi,
>
> I have a jsp page with a form and a number of input buttons.  I  
> would like my form action to differentiate which button has been  
> pressed in order to show different pages.  I have private boolean  
> variables that correspond to each button in my jsp page being  
> pressed, but when my action runs and any button is pressed, all of  
> my variables are false and the proper page isn't displayed.  Any  
> clues?
>
> Thanks,
> Session
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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


Mime
View raw message