You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by stanlick <st...@gmail.com> on 2008/03/01 21:33:40 UTC
Strange namespace/action scenario
Is there a limitation on when/where you can use the <s:submit..> tag to
invoke action/methods in a namespace?
This works:
<s:form action="gradeQuiz" namespace="quiz" method="score">
<s:submit key="gradeMe"/>
This does not:
<s:form>
<s:submit key="gradeMe" action="gradeQuiz" method="score"/>
--
View this message in context: http://www.nabble.com/Strange-namespace-action-scenario-tp15780694p15780694.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Strange namespace/action scenario
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
stanlick wrote:
>
> Here is the current solution:
> <s:form action="gradeQuiz" namespace="quiz">
> <s:submit key="gradeMe" method="score"/>
>
>
>
I avoid using the method attribute of submit. The problem is that it
includes a special prefix on the submit's paramater that the default
action mapper detects, strips and selects that target method of your
action. That's fine and quite nice, however, XML validation works on
the action name only and doesn't know you're calling a special method,
so it may run the wrong validation task or skip validation entirely.
My preference is to use wildcards so the action name contains the method
name.
<s:form action="gradeQuiz" namespace="quiz">
<s:submit key="gradeMe" action="gradeQuizScore"/>
where the action is defined as
<action name="grateQuiz*" method="{1}" ...
In this case, the action attribute of the form is completely ignored and
each button can point to a different action and method in the namespace.
I don't recall whether AnnotationValidation allows you to run different
validation on different methods in the same action (it never used to
work). If that works now the problem is avoided.
>
> Anyways, I am still a bit confused as to why the attributes need to be
> distributed across the two tags to get this to work correctly. It seems
> like maybe the namespace should be an attribute of the submit tag or else
> the action-method an attribute of the form! The only error I was seeing had
> to do with the goofy ParametersInterceptor<sp?> and it had me chasing my
> tail far too long! Far too long!!!
>
>
>
I agree it's confusing. I think it goes back to early versions of
webwork and that's the way it works. I think the struts2 has moved on
but the tags are much the same.
When I've needed to use a different namepace for a button I've used
javascript to change the action of the form prior to submit.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Strange namespace/action scenario
Posted by stanlick <st...@gmail.com>.
Alright! In my pursuit of a solution, I blew past the fact that the method
attribute of the <s:form../> tag is the HTTP method! Struts 2 does such a
nice job of lifting you out of the HTTP API's that I actually considered
method to be uhhhhhhhhh...... the method!
Anyways, I am still a bit confused as to why the attributes need to be
distributed across the two tags to get this to work correctly. It seems
like maybe the namespace should be an attribute of the submit tag or else
the action-method an attribute of the form! The only error I was seeing had
to do with the goofy ParametersInterceptor<sp?> and it had me chasing my
tail far too long! Far too long!!!
Here is the current solution:
<s:form action="gradeQuiz" namespace="quiz">
<s:submit key="gradeMe" method="score"/>
stanlick wrote:
>
> Is there a limitation on when/where you can use the <s:submit..> tag to
> invoke action/methods in a namespace?
>
>
> This works:
> <s:form action="gradeQuiz" namespace="quiz" method="score">
> <s:submit key="gradeMe"/>
>
>
> This does not:
> <s:form>
> <s:submit key="gradeMe" action="gradeQuiz" method="score"/>
>
--
View this message in context: http://www.nabble.com/Strange-namespace-action-scenario-tp15780694p15789584.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org