struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wes Wannemacher <w...@wantii.com>
Subject Re: How to specify namespace for s:submit.
Date Sun, 01 Mar 2009 14:56:02 GMT
On Sunday 01 March 2009 08:52:25 Dave Newton wrote:
> Zarar Siddiqi wrote:
> > <s:submit/> submits a <s:form/>.  If you want your two submit buttons
> > to call two different actions, you'll need two different forms.
>
> <s:submit> can submit to different actions, I'm just not sure if the
> namespace can be specified.
>
> Dave
>

I thought we used to have an s:button for just this situation, I can't find it 
anywhere though... This could be done pretty easily with some javascript, add 
a button to the form, then put something like this in the onclick handler - 

(untested, more like pseudo-code )

"document.formName.action="<s:url action="otherAction" 
namespace="/otherNs"/>"; document.formName.submit();"

I would suggest being a bit careful changing the form action... Just keep 
track of where you are pointing if you more than one handler that changes it. 

Another option would be to refactor your actions a bit. Add another action 
that your form submits to, then depending on the values submitted, then 
perform the logic in Action1 or Action2, or dispatch to one or the other based 
on the input. 

-Wes

-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


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


Mime
View raw message