Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2443

Allow CodeBehind Result Annotations to be Overridden by Child Classes

    XMLWordPrintableJSON

Details

    • Patch

    Description

      I'm in edge struts 2 (2.1.1-SNAPSHOT), so I'm not sure if this is a problem in 2.0.11.

      When using codebehind, I expected that if a parent class has a @Result annotation with a given name, and a child class has a Result annotation with the same name, that the child annotation would "override" any parent results of the same name. This would seem like expected inheritence behavior (at least to me). It appears that annotations are being taken in the opposite order (parent overrides child setting).

      example:

      @Result(name="input", value="parent.action")
      parentClass

      @Result(name="input", value="chlid.action")
      childClass extends parentClass

      currently the childClass will go to /parent.action, instead of child.action

      Looking through the code, it looks like when the ResultMap is being created, it loops from the current class to the superclass, each time overwriting with parent class results. Is this something intended, or can it be changed to work in reverse? The change is simple - just do a check if the entry already exists in the map before inserting.

      Attachments

        1. patchfile.txt
          1 kB
          Blake Byrnes

        Activity

          People

            mrdon Donald J. Brown
            blakeb Blake Byrnes
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: