struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Todd Perry (JIRA)" <j...@apache.org>
Subject [jira] Commented: (WW-2297) Using ServletActionRedirectResult (within @Result) and extra parameters.
Date Thu, 07 Aug 2008 22:42:25 GMT

    [ https://issues.apache.org/struts/browse/WW-2297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44535#action_44535
] 

Todd Perry commented on WW-2297:
--------------------------------

This still seems to be a problem.  When I test with the latest trunk as of today, it's logging
the exception in ServletActionRedirectResult.handle, but after the first exception it still
skips the remaining parameters.  Even if I specify the actionName directly:

@Result(name = "success", value = "test2", type = ServletActionRedirectResult.class,
        params = {"actionName", "test2", "id", "1"})
public class TestAction extends ActionSupport
  {
...

It ends up trying to set the 'id' property first, gets the OGNL exception, and never reaches
actionName, presumably because the parameters are not set in order (they appear to be in a
HashMap).  I end up getting the same NPE reported in the description because actionName =
null.

> Using ServletActionRedirectResult (within @Result) and extra parameters.
> ------------------------------------------------------------------------
>
>                 Key: WW-2297
>                 URL: https://issues.apache.org/struts/browse/WW-2297
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.11
>            Reporter: David Artiga
>            Assignee: Don Brown
>             Fix For: 2.1.3
>
>
> Given the following class and annotations:
> @Results(
>    @Result(name = Action.SUCCESS, value = "myAction", type=ServletActionRedirectResult.class,
params = { "param1", "value1" })
> )
> public class MyAction implements Action {
>    ...
> }
> In method 'buildResult' from 'com.opensymphony.xwork2ObjectFactory' class:
>  if (resultClassName != null) {
>             result = (Result) buildBean(resultClassName, extraContext);
>             try {
>             	OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true);
>             } catch (XWorkException ex) {
>                 ...
>             }
> ...
> }
> When dealing with the readult an ognl.NoSuchPropertyException is thrown for property
'param1'. 
> This is not a problem if the action is mapped using a XML file, because "actionName"
property has been set earlier (resultConfig.requestParameters = { "actionName=myAction","param1=value1"}).
> But when using annotations, the requestParameters order changes( {"param1=value1", "actionName=myAction"}),
so when throwing the exception "actioName" has not been set yet, and then the Result created
has no actionName (=null).
> That causes a NullPointerException when trying to process the result.
> Possible patch (inform Ognl to not throw exceptions when setting properties):
> OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, /* --> */ false
/* <-- */ );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message