Params will not always set all parameters in @Result annotation
---------------------------------------------------------------

                 Key: WW-2909
                 URL: https://issues.apache.org/struts/browse/WW-2909
             Project: Struts 2
          Issue Type: Bug
    Affects Versions: 2.1.3
            Reporter: Todd Perry


I have a custom result that implement Result with two setters for 'feedTitle' 
and 'feedDescription'.  When using the @Result annotation:

@Result(name = "feed", type = Feed Result.class, value = "feed",
        params = { "feedTitle", "testTitle",
                        "feedDescription", "testDescription" }
)

The feedTitle is set but not feedDescription.  The problem is in 
com.opensymphony.xwork2.ObjectFactory, buildResult, which calls 
OgnlReflectionProvider.setProperties with the map of properties... the map has 
this content:

{feedTitle=testTitle, location=feed, feedDescription=testDescription}

Struts appears to have added 'location' to the parameters when building the 
map.  Since my Result does not have this property it throws an exception which 
is handled silently in buildResult but it does not set the remaining properties 
in the map (feedDescription).

See my comment on WW-2297 (sorry I did not realize it was closed when I added 
this) showing that this also prevents properties like 'actionName' from being 
set under certain circumstances, which means WW-2297 does not seem to be fully 
fixed.  The map order seems to be arbitrary (I assume it's backed by a hash 
map) so it is not possible to make sure the Result properties appear first to 
prevent the exception from interfering.  So this problem also prevents me from 
using @Result to place arbitrary parameters on the value stack, which it 
appears to be meant for as well.

A workaround for this is that I can add a 'setLocation' to my result to handle 
the internal property.. but it does not solve the situation in WW-2297 when 
trying to pass parameters to an internal result type like 
ServletActionRedirectResult.

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

Reply via email to