portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r895688 - /portals/jetspeed-2/portal/branches/JETSPEED-2.1.4/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
Date Mon, 04 Jan 2010 16:43:23 GMT
Author: woonsan
Date: Mon Jan  4 16:43:17 2010
New Revision: 895688

URL: http://svn.apache.org/viewvc?rev=895688&view=rev
Log:
JS2-1091: Fixing the problem that it doesn't display portlet window's title when the portlet
window is out-of-service.

Modified:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.4/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.4/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.4/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java?rev=895688&r1=895687&r2=895688&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.4/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.4/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
Mon Jan  4 16:43:17 2010
@@ -63,6 +63,7 @@
 import org.apache.jetspeed.util.ArgUtil;
 import org.apache.jetspeed.util.Path;
 import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.window.PortletWindow;
 import org.apache.velocity.context.Context;
 
 /**
@@ -741,13 +742,17 @@
         {
             try
             {
-
-                return titleService.getDynamicTitle(windowAccess.getPortletWindow(f), getRequestContext().getRequest());
+                title = titleService.getDynamicTitle(windowAccess.getPortletWindow(f), getRequestContext().getRequest());
+                
+                if (title == null)
+                {
+                    title = getTitleFromPortletDefinition(entity);
+                }
             }
             catch (Exception e)
             {
                 log.error("Unable to reteive portlet title: " + e.getMessage(), e);
-                return "Title Error: " + e.getMessage();
+                title = "Title Error: " + e.getMessage();
             }
         }
 
@@ -766,17 +771,25 @@
      */
     public String getTitle(PortletEntity entity)
     {
+        String title = null;
+        
         try
         {
-            return titleService.getDynamicTitle(windowAccess.getPortletWindow(getCurrentFragment()),
+            title = titleService.getDynamicTitle(windowAccess.getPortletWindow(getCurrentFragment()),
                     getRequestContext().getRequest());
+            
+            if (title == null)
+            {
+                title = getTitleFromPortletDefinition(entity);
+            }
         }
         catch (Exception e)
         {
             log.error("Unable to reteive portlet title: " + e.getMessage(), e);
-            return "Title Error: " + e.getMessage();
+            title = "Title Error: " + e.getMessage();
         }
-
+        
+        return title;
     }
 
     public Object getComponent(String name)
@@ -870,5 +883,26 @@
         renderer.renderNow(contentFragment, context);
         return contentFragment.getRenderedContent();
     }
+    
+    private String getTitleFromPortletDefinition(PortletEntity entity)
+    {
+         String title = null;
+         
+         if (entity != null && entity.getPortletDefinition() != null)
+         {
+             title = requestContext.getPreferedLanguage(entity.getPortletDefinition()).getTitle();
+         }
+         
+         if (title == null && entity.getPortletDefinition() != null)
+         {
+             title = entity.getPortletDefinition().getName();
+         }
+         else if (title == null)
+         {
+             title = "Invalid portlet entity " + entity.getId();
+         }
+         
+         return title;
+    }
 
 }



---------------------------------------------------------------------
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