[
https://issues.apache.org/jira/browse/WW-3276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13222474#comment-13222474
]
JB commented on WW-3276:
------------------------
I have a few comments regarding this issue...
First, the attached demo application, demo.war, is configured incorrectly. The
@Action annotations are configured correctly; however the JSP result for the
@Action("deletegroup") does not exist. There are a couple of JSPs that appear
to be intended as results however they are not named correctly to qualify for
"Conventional" result discovery. For example, demo-delete-success.jsp should
be named deletegroup-success.jsp [1].
Second, the Struts 2 "Intelligent Default" result-string is "success"; however
the string is misspelled within the class twice (e.g., "sucess"). After
correcting this misspelling the application still does not work properly. The
reason is that the <s:url/> tag is utilized to construct the text for the
<s:submit/> button's "action=" attribute. This results in mark-up similar to
the following for each row of table data being generated:
action:deletegroup?deleteId=1.
The DefaultActionMapper [2] deconstructs the string as an action (i.e., action:
) and attempts to locate an @Action annotation named "deletegroup?deleteId=1"
which does not exist. The annotation directs requests for action "deletegroup"
to the delete method which is decorated with the previously mentioned @Action
annotation.
During my testing I set an anchor tags href attribute to the value configured
by the <s:url/> tag. After renaming the JSP demo-delete-success.jsp to
deletegroup-success.jsp I was able to exercise the @Action("deletegroup")
successfully.
To close I would like to suggest that the user was using the <s:submit/> tag
incorrectly. The user was attempting to include a query-string (i.e.,
?deleteId=2) along with "action:deletegroup" designation of the <s:submit/>
tags action attribute. The button will perform a post back to the action
marked by the @Action("entry") annotation because the JSP's form tag is
configured as such.
I would suggest a couple of things: One, a hidden input field could be set by
JavaScript with the appropriate deleteId value when the corresponding button is
clicked. The value would be posted to the Action, provided a value exists to
accept the value, and the action could operate on the property.
Second, "I think" a custom ActionMapper could be created by a user to parse
query-string syntax from the ActionMapping value and then set the appropriate
values on the Action instance. I suppose this could "possibly" qualify as an
enhancement; however I am not sure that feature would/should be included in the
core.
If there is another way to handle the above request please enlighten me;
otherwise I think this issue should be marked as an enhancement or closed
entirely.
Best,
JB
[1]
http://struts.apache.org/2.1.6/docs/convention-plugin.html#ConventionPlugin-Resultsandresultcodes
[2]
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/
> Convention plugin fails to resolve action/method correctly
> ----------------------------------------------------------
>
> Key: WW-3276
> URL: https://issues.apache.org/jira/browse/WW-3276
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Convention
> Affects Versions: 2.1.6
> Environment: Eclipse IDE on both Windows & OpenSuse 11.2 with Tomcat
> 2.0.18
> Reporter: Roger Rached
> Fix For: 2.5
>
> Attachments: demo.war
>
>
> Each button has the URL - action:deletegroup?deleteId=x where x is the index
> of the list. If action DemoDelete has the @Annotation @Action("deletegroup")
> then Struts throws a no action fund. Change the @Annotation to
> @Action("deletegroup?deleteId=2") and press the appropriate button then the
> delete method gets called. However, Struts then throws No result defined for
> action com.blackbox.actions.DemoDelete and result sucess The error thrown
> doesn't seem to relate to what can't be found. I've noticed that once I start
> using @Action notations, Struts seems to get confused and the error messages
> are misleading. For example, remove entry-input.jsp and Struts error message
> throws No result defined for action com.blackbox.actions.DemoDelete and
> result input which is extemely confusing when what it seems to be looking for
> is entry-input.jsp.
> I have a demo.war file available if ou can tell me where to send/upload
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira