I would think the two approaches are quite different in the sense that.
1- Forwards to different actions based on the struts-config setup clutter with lot of actions having repetitive code, and struts-config have to define all the actions to forward to.... 2- Sends to the same action reducing the no of action classes you have to maintain. And As many previous discussions suggested you can have commmon code between the different "hook" methods from an action. Rajesh -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 29, 2002 3:17 PM To: Struts Users Mailing List Subject: RE: Struts and Many Buttons on Single page That is a good alternative too. There is not much difference - in one case you inherit from a routing action and have the code to be executed for a given button separated by methods within a single action, in the case I posted you keep sepatate actions for the routing and the targets based on button press. If you like the routing explicit in the struts config, I think the route action as an added step has more to recommend it. You can change the action to be executed by a given button press by only making XML changes, not code changes. If you don't like a cluttered struts config, the approach you reference will be better. Jim Weaver Software Developer - ThoughtWorks "Rajesh Kalluri" <rkalluri@manduca To: "Struts Users Mailing List" <[EMAIL PROTECTED]> .com> cc: Subject: RE: Struts and Many Buttons on Single page 08/29/2002 12:47 PM Please respond to "Struts Users Mailing List" Use a LookupDispatch Action, very convenient no java script no logic branching. (For more info look at Ted Husteds struts tips) Have your buttons setup like this... <html:submit> <bean:message key="button.edit"/> </html:submit> <br/> <html:submit> <bean:message key="button.relate"/> </html:submit> Action looks like this ...you have to map all your buttons to methods in this class and struts takes care of running your method based on the button submitted. public class ArticleAction extends LookupDispatchAction { protected Map getKeyMethodMap() { Map map = new HashMap(); map.put("button.edit", "view"); map.put("button.relate", "relate"); map.put("button.new.article", "newArticle"); map.put("button.view", "view"); map.put("button.remove.related", "remove"); return map; } public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return getArticle(mapping, form, request,articleId); } -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 29, 2002 1:08 PM To: Struts Users Mailing List Subject: Re: Struts and Many Buttons on Single page Have been through this one; originally used option 2 (javascript to on button click to change action), but as we use httpunit to acceptance test, which does not support javascript, we migrated to a third option: Have a generic action to route based on button pressed. In the html: <html:form action="/routeThisForm"> <html:submit property="SubmitButton_A"/> <html:submit property="SubmitButton_B"/> ... In struts config.xml: <action path="/routeThisForm" type = "com.whatever.GenericSubmitRouteAction" ... <forward name="A" path="/A_Action.do"/> <forward name="B" path="/B_Action.do"/> </action> The code for the generic submit route action looks for which button was pressed, and maps to the appropriately named forwarding. If anyone is interested in this approach I'll post the code for the routing action. It would be nice if Struts somehow supported this sort of thing (forms with multiple actions based on submit button pressed) inherently. Jim Weaver Software Developer - ThoughtWorks [EMAIL PROTECTED] "Renato Aganippe" <raganippe@cardiw To: "Struts Users Mailing List" <[EMAIL PROTECTED]> eb.com> cc: Subject: Re: Struts and Many Buttons on Single page 08/29/2002 11:22 AM Please respond to "Struts Users Mailing List" 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]> -- 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]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>