You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Bruns <br...@gmail.com> on 2007/02/08 01:39:53 UTC
struts2 newbie question
Hi all,
I'm building a non-essential app in struts2 to get my feet wet and ran into
something right away. We make heavy use of LookupDispatchAction in struts1
and I'm having trouble figuring out how to do the same thing in struts2.
I see from the docs that you can use wildcards to map "saveFoo" and
"retrieveFoo" to map to save() and retrieve() respectively but how does one
use a single action and control which method is called based on, for
instance, the value of the submit button?
Thanks in advance,
Brian
Re: struts2 newbie question
Posted by Dale Newfield <Da...@Newfield.org>.
Dave Newton wrote:
> Hrm. Did you try it? I didn't actually see an example
> on the http://cwiki.apache.org/WW/submit.html page
> that used <s:submit.../>'s 'method' attribute.
D'oh. I was looking at example 4 and mistook the s:form tag as a
s:submit tag. Glad it does what you want.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: struts2 newbie question
Posted by Dave Newton <ne...@yahoo.com>.
--- Dale Newfield <Da...@Newfield.org> wrote:
> Dave Newton wrote:
> > http://cwiki.apache.org/WW/submit.html
> > Submit takes both action and method parameters;
> > perhaps that's what you're looking for?
>
> The example makes me think that the method attribute
> enables the ability to specify "get" vs. "post" on a
> submit button by submit button basis
> within a single form (presumably via javascript).
Hrm. Did you try it? I didn't actually see an example
on the http://cwiki.apache.org/WW/submit.html page
that used <s:submit.../>'s 'method' attribute.
Anyway, setting the 'method' attribute allows you to
choose which method in the form's action is run, like
the docs say.
<s:form action="submitTests" method="post">
<s:submit/>
<s:submit method="sub1"/>
</s:form>
Naked submit:
2007-02-08 07:32:29,437 DEBUG
s2samples.forms.SubmitTestsAction.execute:31 - Enter.
Method attribute set:
2007-02-08 07:29:36,328 DEBUG
s2samples.forms.SubmitTestsAction.sub1:20 - Enter.
Dave
____________________________________________________________________________________
Don't get soaked. Take a quick peak at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: struts2 newbie question
Posted by Dale Newfield <Da...@Newfield.org>.
Dave Newton wrote:
> http://cwiki.apache.org/WW/submit.html
>
> Submit takes both action and method parameters;
> perhaps that's what you're looking for?
The example makes me think that the method attribute enables the ability
to specify "get" vs. "post" on a submit button by submit button basis
within a single form (presumably via javascript).
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: struts2 newbie question
Posted by Dave Newton <ne...@yahoo.com>.
--- Brian Bruns <br...@gmail.com> wrote:
> [...] but how does one use a single action and
control
> which method is called based on, for instance, the
> value of the submit button?
http://cwiki.apache.org/WW/submit.html
Submit takes both action and method parameters;
perhaps that's what you're looking for?
d.
____________________________________________________________________________________
Get your own web address.
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org