You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2013/07/19 09:40:49 UTC

[jira] [Updated] (WW-4144) Have ObjectFactory buildResult obey ParameterNameAware restrictions for a Result

     [ https://issues.apache.org/jira/browse/WW-4144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-4144:
------------------------------

    Attachment: WW-4144.patch

First attempt to restrict which parameters to set on Result. Also extended a bit ObjectFactory to use dedicated builder to build results - so you can define your own builder without messing with the whole ObjectFactory
                
> Have ObjectFactory buildResult obey ParameterNameAware restrictions for a Result
> --------------------------------------------------------------------------------
>
>                 Key: WW-4144
>                 URL: https://issues.apache.org/jira/browse/WW-4144
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.15.1
>            Reporter: Jasper Rosenberg
>            Priority: Minor
>              Labels: ObjectFactory
>             Fix For: 2.3.16
>
>         Attachments: WW-4144.patch
>
>
> com.opensymphony.xwork2.ObjectFactory#buildResult(ResultConfig, Map), injects all of the resultConfig parameters into the result after it has been built.  
> However, I'd like to be able to have my Result implement ParameterNameAware, and then have buildResult obey its acceptableParameterName() result so I can filter out what parameters can be injected.
> I'm sorry I don't have a proper patch, but it is a very small change.  Only call setProperty on the result if it is not ParameterNameAware, or it is and the parameter name is acceptable.
> {code:java} 
> if ((!(result instanceof ParameterNameAware)) || (((ParameterNameAware) result).acceptableParameterName(paramEntry.getKey()))) {
>     reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), result, extraContext, true);
> }
> {code}
> I have been running a Struts 2 app for 6 years with this change in place.  Just getting around to suggesting it as a patch :)
> It does also look like the documentation for ParameterNameAware would need to be updated to reflect that it can also be used for results, not just actions.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira