Struts 2
  1. Struts 2
  2. WW-4144

Have ObjectFactory buildResult obey ParameterNameAware restrictions for a Result

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.15.1
    • Fix Version/s: 2.3.16
    • Component/s: Core Actions
    • Labels:

      Description

      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.

       
      if ((!(result instanceof ParameterNameAware)) || (((ParameterNameAware) result).acceptableParameterName(paramEntry.getKey()))) {
          reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), result, extraContext, true);
      }
      

      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.

      1. WW-4144.patch
        13 kB
        Lukasz Lenart

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Lukasz Lenart
            Reporter:
            Jasper Rosenberg
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development