Author: thomas.heute(a)jboss.com
Date: 2010-09-23 05:35:27 -0400 (Thu, 23 Sep 2010)
New Revision: 4324
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
Log:
JBEPP-482: Page's title and portlet's title are not localizable
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-09-23
09:24:46 UTC (rev 4323)
+++
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-09-23
09:35:27 UTC (rev 4324)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-23
09:24:46 UTC (rev 4323)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-23
09:35:27 UTC (rev 4324)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-09-23
09:24:46 UTC (rev 4323)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-09-23
09:35:27 UTC (rev 4324)
@@ -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
@@ -386,16 +389,6 @@
supportedPublicParams_ = supportedPublicRenderParameters;
}
- public String getDisplayTitle()
- {
- String title = getTitle();
- if (title == null)
- {
- title = getDisplayName();
- }
- return title;
- }
-
public String getDisplayName()
{
if (displayName == null)
@@ -942,4 +935,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:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-09-23
09:24:46 UTC (rev 4323)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-09-23
09:35:27 UTC (rev 4324)
@@ -170,7 +170,6 @@
//
Text markup = null;
- String portletTitle = null;
try
{
@@ -217,8 +216,8 @@
markup = Text.create("");
break;
}
- portletTitle = fragmentResponse.getTitle();
-
+ uicomponent.setConfiguredTitle(fragmentResponse.getTitle());
+
// setup portlet properties
if (fragmentResponse.getProperties() != null)
{
@@ -337,7 +336,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);
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-09-23
09:24:46 UTC (rev 4323)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-09-23
09:35:27 UTC (rev 4324)
@@ -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