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

Plugin not working in Portal environment

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.11.1
    • Fix Version/s: 2.3.7
    • Component/s: Plugin - Tiles
    • Labels:
      None
    • Environment:

      Struts 2.0.11.1, Tiles 2.0.6, Tiles Plugin 2.0.11.1

    • Flags:
      Patch

      Description

      When i try to use Tiles in Portlet environment using the above versions, it does not work. I have done some research and these are my findings.

      ( Step 1) CODE BASE - TILES PLUGIN 2.0.11.1

      In org.apache.struts2.tiles.StrutsTilesRequestContext, this logic is such that it always calls dispatch(), if mask is not ending with ".ftl".

      public void dispatch(String include) throws IOException {
      if (include.endsWith(mask))

      { // FIXME This way FreeMarker results still don't have a content-type! include(include); }

      else

      { super.dispatch(include); }

      }

      ( Step 2) CODE BASE - TILES 2.0.6

      super.dispatch() in the above code calls org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch()

      public void dispatch(String path) throws IOException {
      if (response.isCommitted() || ServletUtil.isForceInclude(request))

      { include(path); }

      else

      { forward(path); }

      }

      Atleast above logic should have worked to call include(), if ServletUtil.isForceInclude(request) returned true.
      ServletUtil.isForceInclude(request) returns true if request.getAttribute(ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME) = =true.

      ( Step 3) CODE BASE - STRUTS 2.0.11.1

      Call to org.apache.struts2.portlet.servlet.PortletServletRequestDispatcher.doForward() throws IllegalStateException.

      public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException

      { throw new IllegalStateException("Not allowed in a portlet"); }

      My guess is, forward() should not be called when the result is of type TilesResult.

      My guess is that we need a fix in Step 1.

      EITHER
      call super.include() instead of calling dispatch()
      OR
      request.setAttribute("org.apache.tiles.servlet.context.ServletTilesRequestContext.FORCE_INCLUDE", new Boolean(true)) before calling super.dispatch().

      Thanks,
      Sridhar.

        Attachments

        1. StrutsTilesRequestContext.java
          5 kB
          Sridhar Reddy T

          Issue Links

            Activity

              People

              • Assignee:
                lukaszlenart Lukasz Lenart
                Reporter:
                sridhar_1000@rediffmail.com Sridhar Reddy T
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: