Multiple html:submit within one form
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   nathan_purdy
Posted On:   Thursday, March 27, 2003 08:17 AM

I am trying to use two html:submit buttons withone one form... I wish to decide within the subsequent Action class where to forward to. My problem is how to determine within the Action class which button was pressed. How do i determine in the Action class which button was pressed? Currently in Form: Within Action class I want to return (mapping.findForward("view")); or return (mapping.findForward("compress")); where "view" and "compress" are declared in struts-config.xml. I'd be very grateful for any direction, even to documentation    More>>
I am trying to use two html:submit buttons withone one form...

I wish to decide within the subsequent Action class
where to forward to. My problem is how to determine within the Action class which button was pressed.

How do i determine in
the Action class which button was pressed?




Currently in Form:








Within Action class I want to


return (mapping.findForward("view"));
or
return (mapping.findForward("compress"));

where "view" and "compress" are declared in struts-config.xml.


I'd be very grateful for any direction, even to documentation


Thanks in advance...    <<Less

Re: Multiple html:submit within one form

Posted By:   M_Olesky  
Posted On:   Thursday, March 27, 2003 09:20 AM

In JSP:







On Form:

String submitType;

And a setter and getter for submitType



In Action:



MyForm theForm = (MyForm)form;
String submitType = theForm.getSubmitType();
if(submitType.equals("View")) {
return mapping.findForward("view");
} else {
return mapping.findForward("compress");
}

Or, just change struts-config.xml to use possible values, and use



return mapping.findForward(submitType);


About | Sitemap | Contact