Uploaded image for project: 'Portals Bridges (Retired)'
  1. Portals Bridges (Retired)
  2. PB-9

Resources overewritten by portlet: need to be restored

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 1.0
    • None
    • struts
    • None
    • JBoss 4.0.2 w/ Tomcat 5x; Liferay Portal 3.6.1; Struts 1.27; JDK 1.4.2_09; WinXP

    Description

      Liferay uses Struts to layout the actual portal itself, and so has message resources stored in the request attributes under the Struts key Globals.MESSAGES_KEY. This gets overwritten by portlets using Struts Bridges, and causes problems later on (at leaast in Liferay) in portal rendering (since messages can longer be found).

      I have created a temporary fix in Liiferay by creating my own StrutsPortlet subclass that saves off the messages before processRequest runs, and restores them afterward. However, I believe this should actually be a part of the default StrutsPortlet provided with bridges, since it could/should really affect any portal framework (potentially).

      The code is VERY simple to implement. Here is the subclass that I created: it is obvious how to incorporate it into the base class:

      <code>
      package com.liferay.portal.apache.bridges;

      import java.io.IOException;

      import javax.portlet.PortletException;
      import javax.portlet.PortletRequest;
      import javax.portlet.PortletResponse;
      import javax.servlet.http.HttpServletRequest;

      import org.apache.portals.bridges.struts.StrutsPortlet;
      import org.apache.struts.Globals;

      /**

      • LiferayStrutsPortlet this portlet adds the additional functionality (over StrutsPortlet) to restore overwritten resources.
      • It works such that:
      • <ul>
      • <li>message resources that were in in the request BEFORE the call to processRequest are saved restored afterward such
      • as to avoid conflicts with resources used for the portal itself (and other struts portlets)</li>
      • </ul>
      • @author James Schopp
      • */
        public class LiferayStrutsPortlet extends StrutsPortlet
        {
        protected void processRequest(PortletRequest request, PortletResponse response,
        String defaultPage, String requestType) throws PortletException,
        IOException
        {
        HttpServletRequest req = getHttpServletRequest(this, request, response);
        Object objMessages = req.getAttribute(Globals.MESSAGES_KEY);

      try

      { super.processRequest(request, response, defaultPage, requestType); }

      finally

      { req.setAttribute(Globals.MESSAGES_KEY, objMessages); }

      }
      }
      </code>

      Attachments

        Activity

          People

            ate Ate Douma
            jamesschopp James Schopp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: