ate 2004/11/26 17:04:12 Modified: portals-bridges/struts/src/java/org/apache/portals/bridges/struts StrutsPortlet.java PortletServlet.java PortletServletRequestDispatcher.java Log: Support for multiple struts portlets (from one PA) on one page: Each portlet now uses a unique StrutsPortletRenderContext session key. Patch submitted by Andreas Steffan. Revision Changes Path 1.7 +3 -1 jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/StrutsPortlet.java Index: StrutsPortlet.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/StrutsPortlet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- StrutsPortlet.java 15 Oct 2004 21:47:25 -0000 1.6 +++ StrutsPortlet.java 27 Nov 2004 01:04:12 -0000 1.7 @@ -98,6 +98,7 @@ public static final String REDIRECT_URL = "org.apache.portals.bridges.struts.redirect_url"; public static final String RENDER_CONTEXT = "org.apache.portals.bridges.struts.render_context"; public static final String ERROR_CONTEXT = "org.apache.portals.bridges.struts.error_context"; + public static final String PORTLET_NAME = "org.apache.portals.bridges.struts.portlet_name"; public static final String ACTION_REQUEST = "ACTION"; public static final String VIEW_REQUEST = "VIEW"; public static final String CUSTOM_REQUEST = "CUSTOM"; @@ -228,6 +229,7 @@ this, request); HttpServletResponse res = servletContextProvider .getHttpServletResponse(this, response); + req.setAttribute(PORTLET_NAME, this.getPortletConfig().getPortletName()); boolean actionRequest = (request instanceof ActionRequest); try { 1.2 +28 -8 jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServlet.java Index: PortletServlet.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PortletServlet.java 29 Jul 2004 22:16:40 -0000 1.1 +++ PortletServlet.java 27 Nov 2004 01:04:12 -0000 1.2 @@ -55,18 +55,38 @@ if (!request.getAttribute(StrutsPortlet.REQUEST_TYPE).equals( StrutsPortlet.ACTION_REQUEST)) { - StrutsPortletRenderContext context = (StrutsPortletRenderContext) request + StrutsPortletRenderContext context = null; + + String portletName = (String) request.getAttribute(StrutsPortlet.PORTLET_NAME); + + String contextKey = StrutsPortlet.RENDER_CONTEXT + "_" + portletName; + context = (StrutsPortletRenderContext) request .getSession(true) - .getAttribute(StrutsPortlet.RENDER_CONTEXT); + .getAttribute(contextKey); if (context != null) { if (log.isDebugEnabled()) + { log.debug("render context path: " + context.getPath()); - request.getSession().removeAttribute( - StrutsPortlet.RENDER_CONTEXT); - if (context.getActionForm() != null) - request.setAttribute(mapping.getAttribute(), context - .getActionForm()); + } + request.getSession().removeAttribute(contextKey); + if (context.getActionForm() != null) { + String attribute = mapping.getAttribute(); + if (attribute != null) { + if (log.isDebugEnabled()) + { + log.debug("Putting form " + context.getActionForm().getClass().getName() + + " into request as " + attribute + " for mapping " + mapping.getName()); + } + request.setAttribute(mapping.getAttribute(), context + .getActionForm()); + } + else if (log.isWarnEnabled()) + { + log.warn("Attribute is null for form " + context.getActionForm().getClass().getName() + + ", won't put it into request for mapping " + mapping.getName()); + } + } if (context.isRequestCancelled()) request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE); if (context.getMessages() != null) 1.2 +3 -3 jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServletRequestDispatcher.java Index: PortletServletRequestDispatcher.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServletRequestDispatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PortletServletRequestDispatcher.java 29 Jul 2004 22:16:40 -0000 1.1 +++ PortletServletRequestDispatcher.java 27 Nov 2004 01:04:12 -0000 1.2 @@ -98,8 +98,8 @@ originURL); } } - req.getSession(true).setAttribute(StrutsPortlet.RENDER_CONTEXT, - context); + String portletName = (String) req.getAttribute(StrutsPortlet.PORTLET_NAME); + req.getSession(true).setAttribute(StrutsPortlet.RENDER_CONTEXT + "_" + portletName, context); } else {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]