You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "David Artiga (JIRA)" <ji...@apache.org> on 2007/11/06 10:56:34 UTC

[jira] Created: (WW-2297) Using ServletActionRedirectResult (within @Result) and extra parameters.

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


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.


[jira] Commented: (WW-2297) Using ServletActionRedirectResult (within @Result) and extra parameters.

Posted by "Guillaume Bilodeau (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43586#action_43586 ] 

Guillaume Bilodeau commented on WW-2297:
----------------------------------------

This seems to be related to WW-2170 which has been fixed in 2.1.1.

> 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
>             Fix For: 2.1.4
>
>
> 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.


[jira] Resolved: (WW-2297) Using ServletActionRedirectResult (within @Result) and extra parameters.

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown resolved WW-2297.
---------------------------

    Resolution: Fixed
      Assignee: Don Brown

Yep, I just fixed this in response to WW-2676

> 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.


[jira] Updated: (WW-2297) Using ServletActionRedirectResult (within @Result) and extra parameters.

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown updated WW-2297:
--------------------------

    Fix Version/s:     (was: 2.1.4)
                   2.1.3

> 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
>             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.


[jira] Commented: (WW-2297) Using ServletActionRedirectResult (within @Result) and extra parameters.

Posted by "Todd Perry (JIRA)" <ji...@apache.org>.
    [ 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.