Struts 2
  1. Struts 2
  2. WW-3282

Portlet namespace added multiple times when building form urls

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.8, 2.3.1.2
    • Fix Version/s: 2.3.4
    • Component/s: Plugin - Portlet
    • Labels:
      None
    • Environment:

      Found in portlet containers Jetspeed 2 and Sitevision

      Description

      When building a form in a portlet, the action path in the portlet URL contains the namespace multiple times, and thus the namespace is not correct.

      This happens in prependNamespace() in PortletUrlHelper where three components are combined to form the complete namespace path.
      1. Portlet namespace
      2. Mode namespace
      3. Tag namespace field (default current action namespace)

      In a simple form where namespace is not declared, and action i executing in is proper mode namespace (ex. /portlet/view). Then 2 is "/portlet/view" and 3 is by default "/portlet/view" and thus complete namespace becomes "/portlet/view/portlet/view"

      Workaround for portlet developers is to set the namespace parameter on the form to "/" which results in only the mode namespace added to the path and thus the correct action is executed.

        Issue Links

          Activity

          Hide
          Leonard Broman added a comment -

          s:url generated urls behave slightly different. While running the portlet as web application the url is generated with the correct namespace and action. However, while running in a container, the parameters need the same workaround as above.

          Show
          Leonard Broman added a comment - s:url generated urls behave slightly different. While running the portlet as web application the url is generated with the correct namespace and action. However, while running in a container, the parameters need the same workaround as above.
          Hide
          Lukasz Lenart added a comment -

          Could you check with the latest Portlet 2 plugin ?

          Show
          Lukasz Lenart added a comment - Could you check with the latest Portlet 2 plugin ?
          Hide
          Leonard Broman added a comment -

          I'm sorry but I'm not working with portlets any more and setting this up to test it is not high priority. I will follow up the portlet bugs if I sometimes end up in a portlet project.

          Show
          Leonard Broman added a comment - I'm sorry but I'm not working with portlets any more and setting this up to test it is not high priority. I will follow up the portlet bugs if I sometimes end up in a portlet project.
          Hide
          Leonard Broman added a comment -

          Back in the portlet business for a quick visit again I stumbled upon this bug. And yes, it still exists as of 2.3.1.2. Tested on Liferay 6.1.0.

          Show
          Leonard Broman added a comment - Back in the portlet business for a quick visit again I stumbled upon this bug. And yes, it still exists as of 2.3.1.2. Tested on Liferay 6.1.0.
          Hide
          Lukasz Lenart added a comment -
          Show
          Lukasz Lenart added a comment - Could you check with http://people.apache.org/builds/struts/2.3.2/ ?
          Hide
          Leonard Broman added a comment -

          Tested with 2.3.2 on Liferay 6.1.0. The bug still exists. I don't think this should be a showstopper for the release, since it's been in there for a while.

          Show
          Leonard Broman added a comment - Tested with 2.3.2 on Liferay 6.1.0. The bug still exists. I don't think this should be a showstopper for the release, since it's been in there for a while.
          Hide
          Lukasz Lenart added a comment - - edited

          Anyway 2.3.2 will be dropped (there are some other problems) and 2.3.3 is just ahead

          But probably I won't be able to solve this issue as I must set up a test environment. And as I have never developed a portlet app it'll take a time Is it possible that you could prepare a demo project for this ?

          Show
          Lukasz Lenart added a comment - - edited Anyway 2.3.2 will be dropped (there are some other problems) and 2.3.3 is just ahead But probably I won't be able to solve this issue as I must set up a test environment. And as I have never developed a portlet app it'll take a time Is it possible that you could prepare a demo project for this ?
          Hide
          Johannes Geppert added a comment -

          I have some Struts2 Portlet Apps maybe I can try to reproduce it.

          Show
          Johannes Geppert added a comment - I have some Struts2 Portlet Apps maybe I can try to reproduce it.
          Hide
          Leonard Broman added a comment -

          I've been trying to figure this out with unit tests but to no avail...

          The easiest way to see this is with the portlet app in the source code tree. Building, deploying and adding a portlet in the liferay container will give you links to few different functions. Like the simple form example. The url to the form action has the action encoded as a parameter like this:

          struts.portlet.action=%2Fview%2FformExample

          Which is correct. But, on the next view, there is a form. In the action url in the form you will find the same parameter:

          struts.portlet.action=%2Fview%2Fview%2FprocessFormExample

          Which has the duplication of the /view namespace. The form is not really broken by this, but when using the convention plugin, it does.

          I'll try to figure out what is going wrong with this.

          Show
          Leonard Broman added a comment - I've been trying to figure this out with unit tests but to no avail... The easiest way to see this is with the portlet app in the source code tree. Building, deploying and adding a portlet in the liferay container will give you links to few different functions. Like the simple form example. The url to the form action has the action encoded as a parameter like this: struts.portlet.action=%2Fview%2FformExample Which is correct. But, on the next view, there is a form. In the action url in the form you will find the same parameter: struts.portlet.action=%2Fview%2Fview%2FprocessFormExample Which has the duplication of the /view namespace. The form is not really broken by this, but when using the convention plugin, it does. I'll try to figure out what is going wrong with this.
          Hide
          Lukasz Lenart added a comment -

          Thanks! I was trying to use struts2-portlet-archetype with pluto but it doesn't work or I don't know how to set up things

          Show
          Lukasz Lenart added a comment - Thanks! I was trying to use struts2-portlet-archetype with pluto but it doesn't work or I don't know how to set up things
          Hide
          Leonard Broman added a comment -

          Heres a patch which fixes this. Can some try it out and see if it doesn't break anything?

          Show
          Leonard Broman added a comment - Heres a patch which fixes this. Can some try it out and see if it doesn't break anything?
          Hide
          Lukasz Lenart added a comment -

          Is it against trunk ? Some changes were already in the code so I'm not sure if all was applied correctly. Could you check with trunk ? Right now I'm reviewing the patch. Thanks!

          Show
          Lukasz Lenart added a comment - Is it against trunk ? Some changes were already in the code so I'm not sure if all was applied correctly. Could you check with trunk ? Right now I'm reviewing the patch. Thanks!
          Hide
          Leonard Broman added a comment -

          I fixed the bug against 2.3.1.2 but tried applying it to trunk ( https://github.com/lbroman/struts2/commit/b18b71abd6cbb83478e1286735860611364b2d9e ). I will check again it again against the latest trunk.

          Show
          Leonard Broman added a comment - I fixed the bug against 2.3.1.2 but tried applying it to trunk ( https://github.com/lbroman/struts2/commit/b18b71abd6cbb83478e1286735860611364b2d9e ). I will check again it again against the latest trunk.
          Hide
          Leonard Broman added a comment -

          Applied it to trunk and works as expected.

          Show
          Leonard Broman added a comment - Applied it to trunk and works as expected.
          Hide
          Lukasz Lenart added a comment -

          Patch applied, thanks! Could you check the latest snapshot build ?

          Show
          Lukasz Lenart added a comment - Patch applied, thanks! Could you check the latest snapshot build ?
          Hide
          Hudson added a comment -

          Integrated in Struts2 #460 (See https://builds.apache.org/job/Struts2/460/)
          WW-3282 Changes logic to add namespace only once when building urls and cleans up code (Revision 1327601)

          Result = SUCCESS
          lukaszlenart :
          Files :

          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/components/PortletUrlRenderer.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletConstants.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletPhase.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletSessionMap.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/PortletActionContext.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DispatcherServlet.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr286Dispatcher.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptor.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
          • /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
          • /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/components/PortletUrlRendererTest.java
          • /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java
          • /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java
          • /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
          • /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
          • /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java
          • /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
          Show
          Hudson added a comment - Integrated in Struts2 #460 (See https://builds.apache.org/job/Struts2/460/ ) WW-3282 Changes logic to add namespace only once when building urls and cleans up code (Revision 1327601) Result = SUCCESS lukaszlenart : Files : /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/components/PortletUrlRenderer.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletConstants.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletPhase.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletSessionMap.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/PortletActionContext.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DispatcherServlet.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr286Dispatcher.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptor.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java /struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/components/PortletUrlRendererTest.java /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java /struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java

            People

            • Assignee:
              Lukasz Lenart
              Reporter:
              Leonard Broman
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development