You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leena Borle <ls...@gmail.com> on 2009/02/27 20:54:17 UTC

How to specify namespace for s:submit.

Hi,
  Probably this questions has been asked before, but could not find answer
on the list.
  How do I specify namespace for <s:submit> tag ? I have two buttons in the
from and both of them call different action from different name space. These
are not AJAX actions
 I tries using <s:param name="namespace" ..> and also tried to give just
action="/namespace1/MyAction". Does not work.
 Is this technically possible ?

Thanks
Leena

Re: How to specify namespace for s:submit.

Posted by Dave Newton <ne...@yahoo.com>.
Zarar Siddiqi wrote:
>> <s:submit> can submit to different actions, I'm just not sure if the
>> namespace can be specified.
> 
> How?

Using the "action" attribute (optionally specifying the method with the 
"method" attribute).

Dave


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


Re: How to specify namespace for s:submit.

Posted by Zarar Siddiqi <za...@gmail.com>.
> <s:submit> can submit to different actions, I'm just not sure if the
> namespace can be specified.

How? Wouldn't the Struts tag just render a form tag with two different
submit buttons and clicking on either one will invoke the action
defined in the form tag? I don't see how this is possible without the
use of JavaScript?


On Sun, Mar 1, 2009 at 8:52 AM, Dave Newton <ne...@yahoo.com> 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
>
>
> ---------------------------------------------------------------------
> 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


Re: How to specify namespace for s:submit.

Posted by Wes Wannemacher <we...@wantii.com>.
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


Re: How to specify namespace for s:submit.

Posted by Leena Borle <ls...@gmail.com>.
Hi,
  Yes, <s:submit> can submit two different actions. It's the problem with
namespace. I don't see a way to specify namespace for <s:submit> tag. I
guess, I will have to add JavaScript. I don't want to use two separate
forms.

Thanks For the help,
Leena

On Sun, Mar 1, 2009 at 5:52 AM, Dave Newton <ne...@yahoo.com> 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
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: How to specify namespace for s:submit.

Posted by Dave Newton <ne...@yahoo.com>.
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


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


Re: How to specify namespace for s:submit.

Posted by Zarar Siddiqi <za...@gmail.com>.
<s:submit/> submits a <s:form/>.  If you want your two submit buttons
to call two different actions, you'll need two different forms.

If you can't do that then you could have an onclick handler for both
the submit buttons and depending on which one the user clicks, you can
change the action value of the form (<s:form
action="ChangeThisUsingJavaScript">).

Zarar



On Fri, Feb 27, 2009 at 2:54 PM, Leena Borle <ls...@gmail.com> wrote:
> Hi,
>  Probably this questions has been asked before, but could not find answer
> on the list.
>  How do I specify namespace for <s:submit> tag ? I have two buttons in the
> from and both of them call different action from different name space. These
> are not AJAX actions
>  I tries using <s:param name="namespace" ..> and also tried to give just
> action="/namespace1/MyAction". Does not work.
>  Is this technically possible ?
>
> Thanks
> Leena
>

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