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

Params will not always set all parameters in @Result annotation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3
    • 2.1.3
    • None
    • None

    Description

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

      @Result(name = "feed", type = FeedResult.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 location property.. but it does not solve the situation in WW-2297 when trying to pass parameters to an internal result type like ServletActionRedirectResult.

      Attachments

        Activity

          People

            Unassigned Unassigned
            perryt Todd Perry
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: