struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jasper Rosenberg (JIRA)" <>
Subject [jira] [Commented] (WW-4144) Have ObjectFactory buildResult obey ParameterNameAware restrictions for a Result
Date Thu, 18 Jul 2013 16:42:49 GMT


Jasper Rosenberg commented on WW-4144:

Hi Lukasz!  

> Do you use exactly the same ParameterNameAware interface as for actions?

As you can see in the code change I'm proposing above, yes, I think the same interface would
work well, though the documentation would have to be updated to reflect this change.

> What do you do if Result doesn't implement ParameterNameAware?
Again, looking at the code above, it behaves exactly like the ParameterInterceptor in that
if the Result doesn't implement ParameterNameAware, it just does the injection always (as
it used to do).

> And how do you use that? Wrap each predefined Result with your custom implementation?
Yes, this came up because I needed to extend ServletActionRedirectResult to take a couple
additional parameters (including "anchor" which I see is now supported since my last struts
upgrade, sweet!).

> Have ObjectFactory buildResult obey ParameterNameAware restrictions for a Result
> --------------------------------------------------------------------------------
>                 Key: WW-4144
>                 URL:
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions:
>            Reporter: Jasper Rosenberg
>            Priority: Minor
>              Labels: ObjectFactory
>             Fix For: 2.3.16
> 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:

View raw message