[gatein-commits] gatein SVN: r5339 - in exo/portal/branches/3.1.x: webui/core/src/main/java/org/exoplatform/webui/application/portlet and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Nov 29 04:27:34 EST 2010


Author: hoang_to
Date: 2010-11-29 04:27:32 -0500 (Mon, 29 Nov 2010)
New Revision: 5339

Modified:
   exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
   exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
   exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
   exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
   exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
Log:
EXOGTN-157: Page 's title and portlet 's title are not localizable

Modified: exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
--- exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl	2010-11-29 08:36:33 UTC (rev 5338)
+++ exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl	2010-11-29 09:27:32 UTC (rev 5339)
@@ -37,14 +37,7 @@
 										<div class="FixHeight">
 											<%
 											if(hasPermission) {
-												if(portletTitle == null || portletTitle.trim().length() < 1) {
-													try {
-														String portletName = uicomponent.getProducedOfferedPortlet().getInfo().getName();
-														print _ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description." + portletName);
-													} catch(Exception e){
-														print uicomponent.getDisplayName();
-													}
-												} else print portletTitle;
+												print uicomponent.getDisplayTitle();
 											} else print "<div class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>";
 											%>
 										</div>
@@ -62,12 +55,8 @@
 			
 		if(portalMode != uiPortalApp.CONTAINER_BLOCK_EDIT_MODE && portalMode != uiPortalApp.APP_BLOCK_EDIT_MODE) {
 			if(uicomponent.getShowInfoBar()) {
-				String title = portletTitle;
+				String title = uicomponent.getDisplayTitle();
 				if(title == null || title.trim().length() < 1)
-					title = uicomponent.getTitle();
-				if(title == null || title.trim().length() < 1)
-					title = uicomponent.getDisplayName();
-				if(title == null || title.trim().length() < 1)
 					title = portletId;
 				/*Begin Window Portlet Bar*/
 				String visibility = "visible";
@@ -292,9 +281,7 @@
 																String portletIcon = uicomponent.getIcon();
 																if(portletIcon == null) portletIcon = "PortletIcon";
 																
-																String title = portletTitle;
-																if(title == null || title.trim().length() < 1)
-																	title = uicomponent.getDisplayTitle();
+																String title = uicomponent.getDisplayTitle();
 																if(title.length() > 30) title = title.substring(0,27) + "...";
 															%>
 															<div class="PortletIcon $portletIcon"><%=hasPermission ? title : _ctx.appRes("UIPortlet.label.protectedContent")%></div>

Modified: exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
===================================================================
--- exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java	2010-11-29 08:36:33 UTC (rev 5338)
+++ exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java	2010-11-29 09:27:32 UTC (rev 5339)
@@ -107,6 +107,8 @@
    {
       try
       {
+    	 //Need to localize portlet title via predefined I18n key javax.portlet.title
+    	 res.setTitle(getTitle(req));
          getPortletApplication().render(req, res);
       }
       catch (Exception ex)

Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java	2010-11-29 08:36:33 UTC (rev 5338)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java	2010-11-29 09:27:32 UTC (rev 5339)
@@ -36,6 +36,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.exoplatform.Constants;
+import org.exoplatform.commons.utils.ExpressionUtil;
 import org.exoplatform.commons.utils.PortalPrinter;
 import org.exoplatform.commons.xml.DOMSerializer;
 import org.exoplatform.container.ExoContainer;
@@ -218,6 +219,7 @@
             if (page != null)
             {
                title = page.getTitle();
+               return ExpressionUtil.getExpressionValue(this.getApplicationResourceBundle(), title);
             }
             else
             {

Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java	2010-11-29 08:36:33 UTC (rev 5338)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java	2010-11-29 09:27:32 UTC (rev 5339)
@@ -159,6 +159,9 @@
 
    private StateString navigationalState;
 
+   /** A field storing localized value of javax.portlet.title * */
+   private String configuredTitle;
+
    public UIPortlet()
    {
       // That value will be overriden when it is mapped onto a data storage
@@ -360,16 +363,6 @@
       supportedPublicParams_ = supportedPublicRenderParameters;
    }
 
-   public String getDisplayTitle()
-   {
-      String title = getTitle();
-      if (title == null)
-      {
-         title = getDisplayName();
-      }
-      return title;
-   }
-
    public String getDisplayName()
    {
       if (displayName == null)
@@ -912,4 +905,38 @@
    {
       this.navigationalState = navigationalState;
    }
+   
+   protected void setConfiguredTitle(String _configuredTitle)
+   {
+      this.configuredTitle = _configuredTitle;
+   }
+
+   /**
+    * Returns the title showed on the InfoBar. The title is computed in following manner.
+    * <p/>
+    * 1. First, the method getTitle(), inherited from UIPortalComponent is called. The getTitle() returns what users set
+    * in the PortletSetting tab, the current method returns call result if it is not null.
+    * <p/>
+    * 2. configuredTitle, which is the localized value of javax.portlet.title is returned if it is not null.
+    * <p/>
+    * 3. If the method does not terminate at neither (1) nor (2), the configured display name is returned.
+    *
+    * @return
+    */
+   public String getDisplayTitle()
+   {
+      String displayedTitle = getTitle();
+      if (displayedTitle != null && displayedTitle.trim().length() > 0)
+      {
+         return displayedTitle;
+      }
+
+      if (configuredTitle != null)
+      {
+         return configuredTitle;
+      }
+
+      return getDisplayName();
+
+   }
 }
\ No newline at end of file

Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java	2010-11-29 08:36:33 UTC (rev 5338)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java	2010-11-29 09:27:32 UTC (rev 5339)
@@ -170,7 +170,6 @@
 
       //
       Text markup = null;
-      String portletTitle = null;
 
       try
       {
@@ -219,8 +218,9 @@
                 		  markup = Text.create("");
                 		  break;
                 	  }
-                	  portletTitle = fragmentResponse.getTitle();
-
+                	  
+                	  uicomponent.setConfiguredTitle(fragmentResponse.getTitle());
+                	  
                 	  // setup portlet properties
                 	  if (fragmentResponse.getProperties() != null)
                 	  {
@@ -339,7 +339,6 @@
          WebuiBindingContext bcontext = new WebuiBindingContext(resolver, context.getWriter(), uicomponent, prcontext);
          bcontext.put(UIComponent.UICOMPONENT, uicomponent);
          bcontext.put("portletContent", markup);
-         bcontext.put("portletTitle", portletTitle);
          try
          {
             renderTemplate(uicomponent.getTemplate(), bcontext);



More information about the gatein-commits mailing list