You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by wo...@apache.org on 2010/01/04 17:41:18 UTC

svn commit: r895687 - /portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java

Author: woonsan
Date: Mon Jan  4 16:41:08 2010
New Revision: 895687

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

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

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java?rev=895687&r1=895686&r2=895687&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java Mon Jan  4 16:41:08 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