in ur action handler u can do a getParameters(request) into a hashtable and
then
do a request.getParameterValues(name) for each of them.

 Once u have the name of the button which have pressed then u can do
something lik given below



if (parameters.containsKey("submit")) {
         submitValues = (HashSet)parameters.get("submit");
         Iterator it = submitValues.iterator();
         String option ="";
         while (it.hasNext()) {
           option = (String)it.next();
         }
        if (option.equalsIgnoreCase("add")) {
                          return mapping.findForward("addsuccessful");
          }
}


And then in ur struts config file there has to be an entry for the
actionhandler which wud then redirect to a jsp . Let me know if i have been
clear enuf.

cheers
susmita


-----Original Message-----
From: Renato Aganippe [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 29, 2002 12:22 PM
To: Struts Users Mailing List
Subject: Re: Struts and Many Buttons on Single page


Hi,

I see two solution for this.

1) For each button, you can define a different form with a different action
attribute


2) You can use a javascript function to change the action attribute

Ex:
<script language=JavaScript>
        function doSubmit(val) {
                if (val==1) {
                        document.forms.consult.action='/save.do';
                }
                else if (val==2) {
                        document.forms.consult.action='/remove.do';
                }
                document.forms.consult.submit();
        }
</script>

<html:form name="consult" type="ActionForm" action="/save.do">

<input type=button class=simpletext value=Valider
onClick="doSubmit(1);return false;">
<input type=button value="Delete" class="simpletext" onClick="if
(confirm('Etes vous certain de vouloir supprimer cet enregistrement ?'))
doSubmit(2); return false;">

</html:form>

Hope it will help,

Renato

----- Original Message -----
From: "Ashish Kulkarni" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, August 29, 2002 4:31 PM
Subject: Struts and Many Buttons on Single page


>
> Hi,
>
> I am developing a struts applicatian, I have a jsp page where i have 5
buttons, say Add, Change,Delete, Display.
>
> When i click these buttons they must call different jsp with different
parameters, how can i do it???
>
> Ashish
>
>
> A$HI$H
>
>
> ---------------------------------
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to