portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smi...@apache.org
Subject svn commit: r481215 - /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
Date Fri, 01 Dec 2006 10:07:51 GMT
Author: smilek
Date: Fri Dec  1 02:07:49 2006
New Revision: 481215

URL: http://svn.apache.org/viewvc?view=rev&rev=481215
Log:
added optional DynamicTitleService argument to PortletRenderer ctor for adding the portlet
title to portlet pipeline response in an http response header (JS_PORTLET_TITLE)

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java?view=diff&rev=481215&r1=481214&r2=481215
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
Fri Dec  1 02:07:49 2006
@@ -18,6 +18,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.PortalReservedParameters;
@@ -35,6 +36,7 @@
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.services.title.DynamicTitleService;
 import org.apache.jetspeed.statistics.PortalStatistics;
 import org.apache.jetspeed.util.JetspeedObjectID;
 import org.apache.pluto.PortletContainer;
@@ -61,26 +63,34 @@
     protected PortletContainer container;
     protected PortletWindowAccessor windowAccessor;
     protected PortalStatistics statistics;
+    protected DynamicTitleService addTitleService;
 
     public PortletRendererImpl(PortletContainer container, 
                                PortletWindowAccessor windowAccessor,
                                WorkerMonitor workMonitor,
-                               PortalStatistics statistics)
+                               PortalStatistics statistics,
+                               DynamicTitleService addTitleService)
     {
         this.container = container;
         this.windowAccessor = windowAccessor;
         this.workMonitor = workMonitor;
         this.statistics = statistics;
+        this.addTitleService = addTitleService;
     }
 
     public PortletRendererImpl(PortletContainer container, 
-            PortletWindowAccessor windowAccessor,
-            WorkerMonitor workMonitor)
+                               PortletWindowAccessor windowAccessor,
+                               WorkerMonitor workMonitor,
+                               PortalStatistics statistics)
     {
-        this.container = container;
-        this.windowAccessor = windowAccessor;
-        this.workMonitor = workMonitor;
-        this.statistics = null;
+        this( container, windowAccessor, workMonitor, statistics, null );
+    }
+    
+    public PortletRendererImpl(PortletContainer container, 
+                               PortletWindowAccessor windowAccessor,
+                               WorkerMonitor workMonitor)
+    {
+        this( container, windowAccessor, workMonitor, null );
     }
     
     public void start()
@@ -118,7 +128,7 @@
 
             RenderingJob rJob = buildRenderingJob(fragment, servletRequest, servletResponse,
requestContext);
             rJob.execute();
-
+            addTitleToHeader( portletWindow, fragment, servletRequest, servletResponse );
         }
         catch (Exception e)
         {
@@ -152,6 +162,7 @@
 
             RenderingJob rJob = buildRenderingJob(fragment, servletRequest, servletResponse,
requestContext);
             rJob.execute();
+            addTitleToHeader( portletWindow, fragment, servletRequest, servletResponse );
         }
         catch (Exception e)
         {
@@ -185,7 +196,8 @@
             servletRequest = requestContext.getRequestForWindow(portletWindow);
             servletResponse = dispatcherCtrl.getResponseForWindow(portletWindow, requestContext);
             RenderingJob rJob = buildRenderingJob(fragment, servletRequest, servletResponse,
requestContext);
-            workMonitor.process(rJob);            
+            workMonitor.process(rJob);
+            addTitleToHeader( portletWindow, fragment, servletRequest, servletResponse );
         }
         catch (Exception e1)
         {
@@ -259,7 +271,28 @@
         request.setAttribute(PortalReservedParameters.PORTLET_WINDOW_ATTRIBUTE, portletWindow);
         PortletContent portletContent = dispatcher.getPortletContent(fragment);
         fragment.setPortletContent(portletContent);
+        
         return new RenderingJobImpl(container, portletContent, fragment, request, response,
requestContext, portletWindow, statistics);
-
+    }
+    
+    protected void addTitleToHeader( PortletWindow portletWindow, ContentFragment fragment,
HttpServletRequest request, HttpServletResponse response )
+    {
+        if ( this.addTitleService != null )
+        {
+            try
+            {
+                String title = fragment.getTitle();
+                if ( title == null )
+                {
+                    title = addTitleService.getDynamicTitle( portletWindow, request );
+                }
+                log.info( "PortletRenderer title: " + title );
+                response.setHeader( "JS_PORTLET_TITLE", StringEscapeUtils.escapeHtml( title
) );
+            }
+            catch (Exception e)
+            {
+                log.error("Unable to reteive portlet title: " + e.getMessage(), e);
+            }
+        }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message