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

Parameters which are added via ServletDispatcherResult aren't availabe in #parameters

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.10
    • Fix Version/s: 2.5.12
    • Component/s: Core Results, Value Stack
    • Labels:
      None

      Description

      before Version 2.5.5 the parameters were accessible via #parameters (example: #parameters.foo)
      now I won't get the parameters which are defined via location, only the request parameters

      I have an action like this

      MyTest.java
      @Action(value = "execute", results = @Result(name = SUCCESS, type = DISPATCHER, location = "index.jsp?foo=bar"))
      public String execute() {
          return super.execute();
      }
      

      and that's the TestCase

      MyTest.java
              @Test
              public void testParameters() throws UnsupportedEncodingException, ServletException {
                      request.addParameter("test", "me");
                      executeAction("/test/dispatcher/execute.html");
                      assertEquals("me", findValueAfterExecute("#parameters.test[0]"));
                      assertEquals("bar", findValueAfterExecute("#parameters.foo[0]"));
              }
      

      my current workaround:

      #attr['com.opensymphony.xwork2.ActionContext.parameters'].foo
      

        Issue Links

          Activity

          Hide
          lukaszlenart Lukasz Lenart added a comment -

          I have tested with Struts 2.5.10.1 and it works (in a real app, not a unittest)

              public String execute() throws Exception {
                  Object value = ServletActionContext.getValueStack(ServletActionContext.getRequest()).findValue("#parameters.test[0]");
                  System.out.println(value);
                  return SUCCESS;
              }
          

          or is it a problem with running this code in a unittest?

          Show
          lukaszlenart Lukasz Lenart added a comment - I have tested with Struts 2.5.10.1 and it works (in a real app, not a unittest) public String execute() throws Exception { Object value = ServletActionContext.getValueStack(ServletActionContext.getRequest()).findValue( "#parameters.test[0]" ); System .out.println(value); return SUCCESS; } or is it a problem with running this code in a unittest?
          Hide
          Michael.Hintenaus@silbergrau.com Michael.Hintenaus@silbergrau.com added a comment -

          Access to Parameter test will work, but access to Parameter foo will not
          work

          [ https://issues.apache.org/jira/browse/WW-4788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15978792#comment-15978792 ]

          unittest)
          (ServletActionContext.getRequest()).findValue("#parameters.test[0]");
          in #parameters
          -------------------------------------------------------------------------------------

          (example: #parameters.foo)
          request parameters
          DISPATCHER, location = "index.jsp?foo=bar"))
          ServletException {
          ("#parameters.test[0]"));
          ("#parameters.foo[0]"));

          Show
          Michael.Hintenaus@silbergrau.com Michael.Hintenaus@silbergrau.com added a comment - Access to Parameter test will work, but access to Parameter foo will not work [ https://issues.apache.org/jira/browse/WW-4788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15978792#comment-15978792 ] unittest) (ServletActionContext.getRequest()).findValue("#parameters.test [0] "); in #parameters ------------------------------------------------------------------------------------- (example: #parameters.foo) request parameters DISPATCHER, location = "index.jsp?foo=bar")) ServletException { ("#parameters.test [0] ")); ("#parameters.foo [0] "));
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit d8284846db6d761ec456d6b495451efa684326ce in struts's branch refs/heads/master from Aleksandr Mashchenko
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=d828484 ]

          WW-4788 Parameters which are added via ServletDispatcherResult aren't availabe in #parameters

          Show
          jira-bot ASF subversion and git services added a comment - Commit d8284846db6d761ec456d6b495451efa684326ce in struts's branch refs/heads/master from Aleksandr Mashchenko [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=d828484 ] WW-4788 Parameters which are added via ServletDispatcherResult aren't availabe in #parameters
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #621 (See https://builds.apache.org/job/Struts-JDK7-master/621/)
          WW-4788 Parameters which are added via ServletDispatcherResult aren't (amashchenko: rev d8284846db6d761ec456d6b495451efa684326ce)

          • (edit) core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java
          • (edit) core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #621 (See https://builds.apache.org/job/Struts-JDK7-master/621/ ) WW-4788 Parameters which are added via ServletDispatcherResult aren't (amashchenko: rev d8284846db6d761ec456d6b495451efa684326ce) (edit) core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java (edit) core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java
          Hide
          aleksandr-m Aleksandr Mashchenko added a comment -

          Michael Hintenaus Should be fixed now. Thanks for reporting!

          Show
          aleksandr-m Aleksandr Mashchenko added a comment - Michael Hintenaus Should be fixed now. Thanks for reporting!
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Thanks Aleksandr Mashchenko but I would like to go deeper with this and clean the ActionContext, there is too many contexts in this context

          Show
          lukaszlenart Lukasz Lenart added a comment - Thanks Aleksandr Mashchenko but I would like to go deeper with this and clean the ActionContext, there is too many contexts in this context
          Hide
          aleksandr-m Aleksandr Mashchenko added a comment -

          Lukasz Lenart +1 I agree. It was rather an easy fix.

          Show
          aleksandr-m Aleksandr Mashchenko added a comment - Lukasz Lenart +1 I agree. It was rather an easy fix.

            People

            • Assignee:
              aleksandr-m Aleksandr Mashchenko
              Reporter:
              Michael Hintenaus Michael Hintenaus
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development