Author: hoang_to
Date: 2010-09-07 06:50:22 -0400 (Tue, 07 Sep 2010)
New Revision: 4064
Modified:
portal/branches/branch-r4047/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
portal/branches/branch-r4047/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
Log:
GTNPORTAL-1379: Update Java code to enable localization of page title
Modified:
portal/branches/branch-r4047/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
---
portal/branches/branch-r4047/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-09-07
09:42:14 UTC (rev 4063)
+++
portal/branches/branch-r4047/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-09-07
10:50:22 UTC (rev 4064)
@@ -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:
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-07
09:42:14 UTC (rev 4063)
+++
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-07
10:50:22 UTC (rev 4064)
@@ -20,6 +20,7 @@
package org.exoplatform.portal.application;
import org.exoplatform.Constants;
+import org.exoplatform.commons.utils.ExpressionUtil;
import org.exoplatform.commons.utils.PortalPrinter;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.portal.config.UserPortalConfigService;
@@ -224,6 +225,7 @@
if (page != null)
{
title = page.getTitle();
+ return
ExpressionUtil.getExpressionValue(this.getApplicationResourceBundle(), title);
}
else
{
Modified:
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-09-07
09:42:14 UTC (rev 4063)
+++
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-09-07
10:50:22 UTC (rev 4064)
@@ -160,6 +160,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
@@ -361,16 +364,6 @@
supportedPublicParams_ = supportedPublicRenderParameters;
}
- public String getDisplayTitle()
- {
- String title = getTitle();
- if (title == null)
- {
- title = getDisplayName();
- }
- return title;
- }
-
public String getDisplayName()
{
if (displayName == null)
@@ -925,4 +918,37 @@
{
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.
+ *
+ * 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.
+ *
+ * 2. configuredTitle, which is the localized value of javax.portlet.title is returned
if it is not null.
+ *
+ * 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:
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
---
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-09-07
09:42:14 UTC (rev 4063)
+++
portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-09-07
10:50:22 UTC (rev 4064)
@@ -218,7 +218,8 @@
break;
}
portletTitle = fragmentResponse.getTitle();
-
+ uicomponent.setConfiguredTitle(portletTitle);
+
// setup portlet properties
if (fragmentResponse.getProperties() != null)
{
@@ -337,7 +338,7 @@
WebuiBindingContext bcontext = new WebuiBindingContext(resolver,
context.getWriter(), uicomponent, prcontext);
bcontext.put(UIComponent.UICOMPONENT, uicomponent);
bcontext.put("portletContent", markup);
- bcontext.put("portletTitle", portletTitle);
+ //bcontext.put("portletTitle", portletTitle);
try
{
renderTemplate(uicomponent.getTemplate(), bcontext);
Modified:
portal/branches/branch-r4047/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
===================================================================
---
portal/branches/branch-r4047/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-09-07
09:42:14 UTC (rev 4063)
+++
portal/branches/branch-r4047/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-09-07
10:50:22 UTC (rev 4064)
@@ -107,6 +107,9 @@
{
try
{
+ //Needed to localize title via predefined I18n key javax.portlet.title
+ res.setTitle(getTitle(req));
+
getPortletApplication().render(req, res);
}
catch (Exception ex)
Show replies by date